samedi 6 avril 2019

How can I get this code to run properly? I'm having issues with the if and else statements and apparently it's not indented correctly

I'm trying to create a program that calculates the stopping distance of a car and I want to make it so that if the use inputs the deceleration as greater than 0 than the program will print "Cannot use positive integers". And also the program is having indention errors with the else statements.

I already played around with the indentation and it doesn't fix anything.

a = raw_input("How quickly is the vehicle decelerating? ")
if a > 0:
        print "cannot be a positive integer"

else a < 0: 
    s1 = (0 - float(u)**2)
    s2 = (2*float(a))
    s = s1/s2
 print "The vehicle will travel %s meters per second before coming to a complete stop" % (s)

Aucun commentaire:

Enregistrer un commentaire