dimanche 31 juillet 2016

Struggles with input in Python 3.4.2 [duplicate]

This question already has an answer here:

I just made little Python program, but I'm getting the same problem all the time. If I type in the input t or S, then the program asks (and calculates) everything what it should do if the input was V. I can't find the place where it's going wrong! Here's my script:

print ('Wat wil je weten: V (snelheid), S (afstand) of t (tijd)? ')
vst_choise = input()

if vst_choise == 'V' or 'v' or 'Snelheid' or 'snelheid':
    print ('Geef de waarde van S (afstand): ')
    s1 = eval(input())
    print ('Geef de waarde van t (tijd) :')
    t1 = eval(input())
    v_ans = s1 / t1
    print ('V (snelheid) = ' + str(v_ans)) 

elif vst_choise == 'S' or 's' or 'Afstand' or 'afstand':
    print ('Geef de waarde van V (snelheid): ')
    v1 = eval(input())
    print ('Geef de waarde van t (tijd) :')
    t2 = eval(input())
    s_ans = v1 * t2
    print ('S (afstand) = ' + str(s_ans)) 

elif vst_choise == 'T' or 't' or 'Tijd' or 'tijd':
    print ('Geef de waarde van V (snelheid): ')
    v2 = eval(input())
    print ('Geef de waarde van S (afstand) :')
    s2 = eval(input())
    t_ans = s2 / v2 
    print ('t (tijd) = ' + str(t_ans))

I hope one of you can solve the problem. Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire