Question: Hello. I am working on a calculator project and everything seems to be fine, but it seems that 2 variables are still remaining at the value of zero. How do I fix the problem?
frames = input("How many frames is the flipnote?\n")
if frames == str(object=''):
print("Do not enter string text.")
if float(frames) > 999:
print("Invalid.")
fps = 0
flipnoteSpeed = input("Choose a flipnote speed from 1-8\n")
if float(flipnoteSpeed) > 8:
print("Choose a number between 1 and 8\n")
if float(flipnoteSpeed) < 1:
print("Choose a number between 1 and 8\n")
flipnoteLength = float(frames) / float(fps)
# coversion of flipnote speed to frames per second
if flipnoteSpeed == 1:
float(fps) == + 0.5
if flipnoteSpeed == 2:
fps = + 1
if flipnoteSpeed == 3:
fps = + 2
if flipnoteSpeed == 4:
fps = + 4
if flipnoteSpeed == 5:
fps = + 6
if flipnoteSpeed == 6:
fps = + 12
if flipnoteSpeed == 7:
fps = + 20
if flipnoteSpeed == 8:
fps = + 30
print(flipnoteLength)
Just do this: if frames == '':
And which two variables are causing your issue?
Also note, flipnote speed is a str, so when you try to do if flipnoteSpeed == 1 it will always be false, as you are comparing int to str. To fix this use '1' instead
basically, you are attempting to divide by 0 because you are using fps instead of flipnoteSpeed since fps is set to 0 and you attempt to divide that. The following code will fix it:
frames = input("How many frames is the flipnote?\n")
if frames == '':
print("Do not enter string text.")
if float(frames) > 999:
print("Invalid.")
fps = float(input("Choose a flipnote speed from 1-8\n"))
if float(fps) > 8:
print("Choose a number between 1 and 8\n")
if float(fps) < 1:
print("Choose a number between 1 and 8\n")
# coversion of flipnote speed to frames per second
if fps == 1:
fps = 0.5
if fps == 2:
fps = 1
if fps == 3:
fps = 2
if fps == 4:
fps = 4
if fps == 5:
fps = 6
if fps == 6:
fps = 12
if fps == 7:
fps = 20
if fps == 8:
fps = 30
flipnoteLength = float(frames) / float(fps)
print(flipnoteLength)