TypeError: not all arguments converted during string formatting python 3 -
ballistic calculator computer science class. can't figure out why keeps giving next error message :
travel_time = range % velocity typeerror: not arguments converted during string formatting print ("welcome laird industries ballistic calculator") range = raw_input("what approximate distance target? (m)") velocity = raw_input("what muzzle velocity of projectile? ") def time_to_target(): travel_time = range % velocity print "travel duration {0}".format(travel_time) # time_to_target() #
thanks info. fixed code :
range_to_target = raw_input("what approximate distance target? (m)") velocity = raw_input("what muzzle velocity of projectile? ") def time_to_target(): travel_time = float(range_to_target) / float(velocity) print "travel duration {0}".format(travel_time) # time_to_target() #
it's because range
string (you got input()
) , %
strings in python special formatting operator. need convert numeric info type, this:
travel_time = float(range) % float(velocity)
python python-2.7
No comments:
Post a Comment