Question

PYTHON Write a program that converts a total number of seconds to hours, minutes, and seconds....

PYTHON

Write a program that converts a total number of seconds to hours, minutes, and seconds. It should (1) prompt the user for input, (2) read an integer from the keyboard, (3) and calculate the result. For example, "5000 seconds = 1 hours, 23 minutes, and 20 seconds".

Hint: Use the modulus operator.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

def convert(time):
    temp=time
    hour = time // 3600
    time %= 3600
    minutes = time // 60
    time %= 60
    seconds = time
    print(temp,"seconds =",hour,"hours",minutes,"minutes",seconds,"seconds.")

time = int(input("Input time in seconds: "))
convert(time)

Add a comment
Know the answer?
Add Answer to:
PYTHON Write a program that converts a total number of seconds to hours, minutes, and seconds....
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
  • C++ Question 6 (10pt): Convert seconds Write a program that takes a number of seconds as...

    C++ Question 6 (10pt): Convert seconds Write a program that takes a number of seconds as user input (as an integer) and converts it to hours, minutes, and seconds as shown below. You should convert the amount of time in such a way that maximizes the whole numbers of hours and minutes. Expected output 1 (bold is user input) Enter a number of seconds: 60 0 hour(s) 1 minute(s) 0 second(s) Expected output 2 (bold is user input) Enter a...

  • Write a program that accepts a number of minutes and converts it both to hours and...

    Write a program that accepts a number of minutes and converts it both to hours and days. For example, 6000 minutes is 100.0 hours or 4.166666666666667 days. Grading Write your Java code in the area on the right. Use the Run button to compile and run the code. Clicking the Run Checks button will run pre- configured tests against your code to calculate a grade.

  • Write a C program convert.c that converts each number in an array by the sum of...

    Write a C program convert.c that converts each number in an array by the sum of that number plus 6 modulus 10. A sample input/output: Enter the length of the array: 5 Enter the elements of the array: 3 928 4 14 77 Output: 9 4 0 0 3 The program should include the following function: void convert(int *a1, int n, int *a2) The function converts every element in array a1 of length n to an output array a2. The...

  • Write a program in Python that accepts as input an integer N and a real number...

    Write a program in Python that accepts as input an integer N and a real number c, and outputs the coefficient of the Nth degree term of the Taylor series for the function f(x) = ex centered at c. This process should recur until the user enters a quit code. Erroneous input should be excepted as necessary, and should result in a new prompt.

  • Python Program 5. Write a Python program in a file named validTime.py. Include a function named...

    Python Program 5. Write a Python program in a file named validTime.py. Include a function named string parameter of the form hh:mm: ss in which these are numeric validTime that takes a values and returns True or False indicating whether or not the time is valid. The number of hours, minutes, and seconds must two digits and use a between 0 and 9). The number of hours must be between 0 and 23, the number of minutes and seconds must...

  • Write a program in which the user is asked to enter, a number of years, days,...

    Write a program in which the user is asked to enter, a number of years, days, hours, minutes and seconds. The program should convert it to seconds. For example, your program should find out how many total seconds are there in 1 year. 135 days, 95 hours, 230 minutes and 60000 seconds. Please write program using Python.

  • Please solve it by Python 3 Write a program that asks the user for a positive...

    Please solve it by Python 3 Write a program that asks the user for a positive integer limit and prints a table to visualize all factors of each integer ranging from 1 to limit. A factor i of a number n is an integer which divides n evenly (i.e. without remainder). For example, 4 and 5 are factors of 20, but 6 is not. Each row represents an integer between 1 and 20. The first row represents the number 1,...

  • Problem 1: Write a program that reads a positive float number and displays the previous and...

    Problem 1: Write a program that reads a positive float number and displays the previous and next integers. Sample Run: Enter a float: 3.5 The previous and next integers are 3 and 4. Problem 2: Write a program that reads two integers and displays their sum, difference, product, and the result of their division. Sample Run: Enter two integers: 8 5 Sum: 8, Difference: 3, Product: 40, Division: 1.6 Problem 3: Write a program that reads a three-digit integer from...

  • . Use what you learned from our First Python Program to write a Python program that...

    . Use what you learned from our First Python Program to write a Python program that will carry out the following tasks. Ask user provide the following information: unit price (for example: 2.5) quantity (for example: 4) Use the following formula to calculate the revenue: revenue = unit price x quantity Print the result in the following format on the console: The revenue is $___. (for example: The revenue is $10.0.) . . Use the following formula to calculate the...

  • Python Programming 4th Edition: Write a program that asks the user for the number of feet....

    Python Programming 4th Edition: Write a program that asks the user for the number of feet. The program converts those feet to inches by using the formula ’12 * feet’. Hint: Define main () program Get the number of feet from the user Define variables Call a function feet_to_inches(feet) The function receives the number of feet and returns the number of inches in that many feet. The output should look like as follows: Enter the number of feet: If the...

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
ADVERTISEMENT