Question: attempts = 0 while attempts < 3 : miles = float ( input ( ' Enter how many miles you want converted: ' ) )
attempts
while attempts :
miles floatinputEnter how many miles you want converted:
if miles :
printYou cannot enter a negative number. Goodbye, William."
attempts
else:
milesToKilometers miles
printfmiles Miles is equal to milesToKilometers:f Kilometers. Amazing!"
if attempts :
printError: You have entered an invalid value three times in a row. Program terminated."
Redesign the solution using functions for the above program with :
define a function named main
get input in the main function and pass it to the following functions:
a milesToKm
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
