A student has to travel a distance of 450 km in a car at a average speed.write python script to find the total amount of time taken to cover the distance?
Answers
Given:
A student has to travel a distance of 450 km in a car at an average speed.
To write:
A python script to find the total amount of time taken to cover the distance
Python Script:
print("*******Time Calculator to cover a Distance*********")
print("Distance to be covered by the Student is 450 km")
a_speed = int(input("Enter the average speed (km/h) of the car to cover the distance: "))
if a_speed <= 0:
print("Invalid Speed. Speed cannot be 0 or less than that")
else:
time_taken = 450/a_speed
print(f"Time taken to complete the distance will be {time_taken} hours")
Explanation:
- In this program, we are considering that the average speed will be entered by the user in km/h.
- The distance to be covered is given as 450 km.
- So we are calculating the time required with the formula →
- We are also checking if the entered speed is 0 or less than that (negative).
- If that is the case, the program will end and ask the user to input the (valid) speed again.
------------------------------------------------------------------------------------
Also View:
Assume s is a string of lower case characters. Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i', 'o', and 'u'.
https://brainly.in/question/18488498
Find and write the output of the following python code:
https://brainly.in/question/12929885
Write a python code for adding two numbers?
https://brainly.in/question/14569524