Computer Science, asked by Hasanur1175, 5 hours ago

Write a python program to calculate speed in km/hr (speed = distance ÷ time)

Answers

Answered by Macaq
5

Answer:

d=float(input("Enter the Distance in Kms:"))

t=float(input("Enter the Time in Hrs:"))

speed=d/t

print("Speed is ",speed," (Km/Hr)")

Keep practicing and keep learning!!!

Answered by KailashHarjo
2

A python program to calculate speed in km/hr:

distance = float(input("Enter the distance in km: "))

time = float(input("Enter the time in hours: "))

speed = distance/time

print("The speed is {:.2f} km/hr".format(speed))

  • The distance and time variables are declared and their values are obtained from the user using the input() function. The values are then converted to float using the float() function.
  • The speed is calculated by dividing the distance by the time and stored in the speed variable.
  • The final result is printed to the console using the print() function and the format() method of string objects. The {:.2f} format specification inside the string is used to format the speed value as a floating-point number with 2 decimal places.

#SPJ3

Similar questions