Calculate speed in Python
input() - Question 20
In this question, we will see how to input distance in kilometer, time in minutes in Python programming using the input() function and find the speed. To know more about input() function click on the input() function lesson.
Q20) Write a program in Python to input distance in kilometer, time in minutes and find the speed.
Formula: Speed = Distance / Time
Program
d=int(input('Enter distance in km '))
t=int(input('Enter time in minutes '))
s=d/t
print('Speed = {:.2f} km per minute'.format(s))
Output
Enter distance in km 70 Enter time in minutes 50 Speed = 1.40 km per minute