Question: #This program converts positive input of miles into Kilometers #If input is negative three times in a row #the program exits def milesToKm ( miles

#This program converts positive input of miles into Kilometers
#If input is negative three times in a row
#the program exits
def milesToKm (miles):
return miles *1.6
def main ():
Invalid_attempts=0
while Invalid_attempts <3:
miles = float(input('Enter how many miles you want converted: '))
if miles <0:
print('You can not enter a negative number goodbye, William.')
Invalid_attempts=Invalid_attempts+1
else:
milesToKilometers = milesToKm (miles)
print(miles,'miles is equal to ', format(milesToKilometers,',.2f'),'Kilometers' )
if Invalid_attempts==3:
print('you can not enter further data')
main()
Need the above program to execute by only passing data from function call to function definition ( Please NO USE of Break/exit/ Return )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!