Ballistic calculator for Computer science class. I can't figure out why it keeps giving the following error message :
travel_time = range % velocity
TypeError: not all arguments converted during string formatting
print ("Welcome to the Laird Industries Ballistic Calculator")
range = raw_input("What is the approximate distance to your target? (m)")
velocity = raw_input("What is the muzzle velocity of the projectile? ")
def time_to_target():
travel_time = range % velocity
print "Travel duration {0}".format(travel_time)
#
time_to_target()
#
Thanks for the info. Fixed code :
range_to_target = raw_input("What is the approximate distance to your target? (m)")
velocity = raw_input("What is the muzzle velocity of the projectile? ")
def time_to_target():
travel_time = float(range_to_target) / float(velocity)
print "Travel duration {0}".format(travel_time)
#
time_to_target()
#
%(the remainder operator) rather than/(the division operator) here?