Question

IN PYTHON Write a program that takes a user-input distance and speed and then calculates an...

  IN PYTHON
   Write a program that takes a user-input distance and speed and then calculates an ETA.
   Your program should work for ANY COMBINATION of distance and speed.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Source Code in Python:

dist=float(input("Input distance in miles: ")) #taking distance input
speed=float(input("Input speed in miles per hour: ")) #taking speed input
if dist<=0 or speed<=0:
print("Invalid Input!")
else:
time=dist/speed #calculating time in hours
hour=int(time) #converting it into whole hours
minute=int((time-hour)*60) #and converting the fractional part into whole minutes
print("ETA:",hour,"hours and",minute,"minutes") #output

Output:

Add a comment
Know the answer?
Add Answer to:
IN PYTHON Write a program that takes a user-input distance and speed and then calculates an...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In python. Write a program that takes 2 string inputs and calculates the Hamming Distance. Hamming...

    In python. Write a program that takes 2 string inputs and calculates the Hamming Distance. Hamming distance between two strings is the number of positions at which the corresponding symbols are different. The program should output an integer representing this distance. For example a = XXWWZZ b = ZZWWXX answer = 4 More examples: "Phone" and "PHOONE" = 3 "God" and "Dog" = 2 "Dog" and "House" = 4

  • Write a Python program: In main function the user is asked to enter distance traveled and...

    Write a Python program: In main function the user is asked to enter distance traveled and time and then send this information to a Python function that calculates and returns the speed of a car. The function will need to have parameters for distance traveled and time taken for the travel. The speed is calculated as: Speed = distance traveled / time In the main function show how to call this function in a print statement.

  • Python Simple Programming Write a program in Python that calculates the tip and total for a...

    Python Simple Programming Write a program in Python that calculates the tip and total for a meal at a restaurant. When your program is run it should ... Calculate the tip and total for a meal for a restaurant Print the name of the application "Tip Calculator" Get input from the user for cost of meal and tip percent Print the tip and total amounts. The formula for calculating the tip amount is: tip = cost of meal * (tip...

  • Question 4-6 Please. Python 3.6. def main(). entered by a user. Write a program that finds...

    Question 4-6 Please. Python 3.6. def main(). entered by a user. Write a program that finds the sum and average of a series of numbers he program should first prompt the user to enter total numbers of numbers are to be summed and averaged. It should then as for input for each of the numbers, add them, and print the total of the numbers and their average 2. Write a progra m that finds the area of a circle. The...

  • Using Python: Write a program that takes the size of a file (in bytes) as input...

    Using Python: Write a program that takes the size of a file (in bytes) as input from the user, coverts it to the nearest whole number binary prefix (B for byte, KB for kilobyte, MB for megabyte, GB for gigabtye), rounded down. Any file sizes greater than 1024 GB should just be converted to GB.

  • how do i write a Python program in function. calc_fuel which takes two input parameters: distance...

    how do i write a Python program in function. calc_fuel which takes two input parameters: distance fuel_consumption. The function should calculate : fuel_needed = distance * fuel_consumption / 100. The function should then return fuel_needed. Now add the following lines at the end of main(): distance = 500 fuel_rate = 8 fuel = get_fuel(distance, fuel_rate) print(“Fuel needed is“, fuel)

  • Write a python program that does the following: takes as input from the user an English...

    Write a python program that does the following: takes as input from the user an English sentence calls the function vc_counter() that: takes a string argument counts the number of vowels and consonants in the string returns a dictionary of the counts, using the keys total_vowels and total_consonants Uses the return from vc_counter() to print the total vowels and consonants with appropriate descriptions. Example: Enter an English sentence: The quick brown fox's jump landed past the lazy dog! Total #...

  • USING PYTHON PLEASE Write a program that calculates the factorial value of a number entered by...

    USING PYTHON PLEASE Write a program that calculates the factorial value of a number entered by the user. Remember that x! =x* (x-1)* (x-2)*... *3+ 2* 1. Your program should check the value input by the user to ensure it is valid (i.e., that it is a number > =1). To do this, consider looking at the is digit() function available in Python. If the user enters an incorrect input, your program should continue to ask them to enter a...

  • Write a Python program with a function that will take as input from the user the...

    Write a Python program with a function that will take as input from the user the temperature in Celsius and will convert and display temperature values in both Fahrenheit and Celsius, using the equation: F = (C ∗ 9/5)+ 32 Note: below is what a sample input line to your program should look like and the resulting output. User input lines always start with >>>. This convention will be used for all of the problem sets. >>>Enter temperature in Celsius:...

  • For Python: Write a program that gets five integer test scores from the user, calculates their...

    For Python: Write a program that gets five integer test scores from the user, calculates their average, and prints it on the screen. Test your program with the following data: Run 1: 40, 80, 97, 32, 87 Run 2: 60, 90, 100, 99, 95

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT