Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Search results

  1. skifli

    Python Floating point numbers subtracting incorrectly

    That won't work for all subtractions.
  2. skifli

    Python Floating point numbers subtracting incorrectly

    This is due to limitations in Binary. You can't practically represent decimals in Binary. For computer purposes `2.5199999999999996` is close enough to `2.52`. See this post.
  3. skifli

    PHP Why does ../ work but not / for relative file paths?

    @Johna Have a look at this.
  4. skifli

    What Linux-Distro Are You Using?

    I dual boot between Windows and Zorin OS 16 Professional.
  5. skifli

    Python Python compiling error (Python Beginner)

    It can't be serialised by the json dumps func since it doesn't know how to handle that type of class. The str function does though.
  6. skifli

    Python Python compiling error (Python Beginner)

    @cbreemer I was talking about the first error. In terms of the second error, it occurs because a datetime object can't be converted to a string. Your solution works because the json dumps function calls the string function on the datetime object since it can't serialise it itself.
  7. skifli

    Python Python compiling error (Python Beginner)

    I think you have got the value to insert and the index to insert args for the `.insert` function the wrong way round. Anyway, I switched to `.append` for simplicity. Try this code. import time import board import adafruit_dht import psutil import io import json import os from datetime import...
  8. skifli

    Python is it possible to call multiple functions from the same line depending on previous events?

    You can also do this: from random import randint # Define the functions def func_1(): return 'This is function 1' def func_2(): return 'This is function 2' def func_3(): return 'This is function 3' # Create a random number from 1 to 4. If 4 is picked the else will fire. num =...
  9. skifli

    Python Does python have good text editing capabilities?

    Slight problem with your code, `listdir` lists folders as well as files so you need to check if each object is a file. Also, `file[-3:]` never would equal `jpeg` since jpeg is four characters long. I would fix that by using `.endswith`. However, l used `splittext` to get the file extensions...
  10. skifli

    Python I'm not sure what this means and if pygame has been installed successfully.

    Your IDE is probably picking up a different installation of python, do you have multiple versions installed?
  11. skifli

    Python How to fix beginner project issue (Guess the Number game)

    from random import randint beg = 1 end = 100 random_integer = randint(beg, end) innum = int(input("input a random number")) if innum < random_integer: print("your number is too small") elif innum > random_integer: print("your number is too big") else: print("you guessed right")
  12. skifli

    Python What's an alternate solution to building a pyramid?

    I do not think there is necessarily anything wrong with the way your code functions. More, it is probably the way it is written. First, you use `str` as a variable. NEVER USE the same names for variables that Python uses. Python uses `str` for the type string, and for the function converting to...
  13. skifli

    Python Python - simple beginner question

    “””Yes, Python does have multiline comments“””
  14. skifli

    Python [Beginner] Why is this not correct?

    Adding the number to itself 4 times is the same as multiplying the number by 4, like so: num = int(input("Enter a number: ")) print(num * 4)
  15. skifli

    Python How do I make this even/odd program work?

    Even better: num = int(input("Input a random number: ")) if num % 2 == 0: print(f"{num} is even.") else: print(f"{num} is odd.")
  16. skifli

    Python Pandas pd.date_range() HELP

    I personally don't use pandas, but you could reverse the list using slice notation, like so: start = dt.datetime(2022,1,1) end = dt.datetime(2023,1,1) dates = pd.date_range (start,end,freq='20D') print(dates)[::-1]
  17. skifli

    Python Newbie here needs help with setting up vscode.

    There are many different Python linters available on the VSCode marketplace. Try the most popular ones to see if it matches the creator of the course's one.
  18. skifli

    Python Newbie here needs help with setting up vscode.

    The Python course creator used a theme for Visual Studio Code. If I am correct, the theme is called `Palenight` (but I'm not entirely sure).
  19. skifli

    Answered Request for Help with List Methods in Python

    areas = [11.25, 18.0, 20.0, 10.75, 9.50] # Print out the index of the element 20.0 print(str(areas.index(20.0))) # Print out how often 9.50 appears in areas print(str(areas.count(9.50))) You use `.index(num)` on a list to get the index of that element in the list. Also for `.count()`, the...
  20. skifli

    Python Request for help with type conversion

    What do they want converted into a string?
Back
Top Bottom