Answer:
In Python:
def MPH(miles,minutes):
mph = round(60 * miles/minutes,1)
return mph
miles = float(input("Miles: "))
minutes = float(input("Minutes: "))
if miles>0 and minutes>0:
print("MPH: ",MPH(miles,minutes))
else:
print("Positive inputs only")
Explanation:
This defines the function
def MPH(miles,minutes):
This calculates mph rounded to 1 decimal place
mph = round(60 * miles/minutes,1)
This returns the calculated mph
return mph
The main begins here
This gets input for miles
miles = float(input("Miles: "))
This gets input for minutes
minutes = float(input("Minutes: "))
If miles and minutes are positive
if miles>0 and minutes>0:
This calls the MPH function
print("MPH: ",MPH(miles,minutes))
If otherwise, this prompts the user for positive inputs
<em>else:</em>
<em> print("Positive inputs only")</em>