Whenever I run the program, no matter what I put as input, the code always goes to the else statement. Even if I state the exact values required for the if and elif statements, it still doesn't work. How do I fix this? Note: I'm a beginner at Python and I use Pycharm.
Code:
import random
print('Welcome to Calculate the Acceleration! \nWe hope you have a fun time!')
choose = input('Type A to choose the formula A = F/M, or V to choose the formula (V1 - V0)/(T2 - T0):')
a_solutions = {'Force = 2, Mass = 1': 2,
'Force = 6, Mass = 3': 2,
'Force = 18, Mass = 3': 6,
'Force = 14, Mass = 7': 2,
'Force = 900, Mass = 45': 20,
'Force = 8, Mass = 2': 4}
v_solutions = {'Starting Velocity = 1, Ending Velocity = 21, Starting Time = 0, Ending Time: 4': 5,
'Starting Velocity = 12, Ending Velocity = 18, Starting Time = 0, Ending Time = 3': 5,
'Starting Velocity = 1, Ending Velocity = 21, Starting Time = 0, Ending Time = 1': 20,
'Starting Velocity = 15, Ending Velocity = 30, Starting Time = 0, Ending Time = 3': 5,
'Starting Velocity = 2, Ending Velocity = 130, Starting Time = 0, Ending Time = 32': 4,
'Starting Velocity = 0, Ending Velocity = 82, Starting Time = 0, Ending Time = 41': 2}
if choose == 'A':
answer_a = input(f"Remember, the formula is A = F/MA. Solve with the following variables: {random.choice(list(a_solutions.values()))}:")
answer_a = int(answer_a)
elif choose == 'V':
print('cs')
else:
while choose != 'A' or 'V':
choose = input('Please try again. \nEnter A or V:')
Result (in console with inputs):
Welcome to Calculate the Acceleration!
We hope you have a fun time!
Type A to choose the formula A = F/M, or V to choose the formula (V1 - V0)/(T2 - T0): 'A'
Please try again.
Enter A or V: V
Please try again.
Enter A or V: 'V'
Please try again.
Enter A or V:
Aucun commentaire:
Enregistrer un commentaire