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
  • Python (Convert milliseconds to hours, minutes, and seconds) Write a function that converts milliseconds to hours,...

    Python (Convert milliseconds to hours, minutes, and seconds) Write a function that converts milliseconds to hours, minutes, and seconds using the following header: def convertMillis(millis): The function returns a string as hours:minutes:seconds. For example, convertMillis(5500) returns the string 0:0:5, convertMillis(100000) returns the string 0:1:40, and convertMillis(555550000) returns the string 154:19:10. Write a test program that prompts the user to enter a value for milliseconds and displays a string in the format of hours:minutes:seconds. Sample Run Enter time in milliseconds: 555550000...

  • Write a C program to converts a number of seconds to days, minutes, hours, and seconds....

    Write a C program to converts a number of seconds to days, minutes, hours, and seconds. Variables days minutes hours seconds Execution sample How many seconds? 234567 Days:      2 Hours:     17 Minutes:   9 Seconds:   27

  • 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.

  • Python Please help Write a program that asks the user to enter a number of seconds...

    Python Please help Write a program that asks the user to enter a number of seconds and then prints the same amount of time in days, hours, minutes, and seconds. For example, 3667 seconds is equivalent to 0 days, 1 hour, 1 minute, and 7 seconds. Print out the result in the format: "0 day(s), 1 hour(s), 1 minute(s), and 7 second(s)." SAMPLE RUN #4: python3 TimeCalculator.py Interactive SessionStandard InputStandard Error (empty)Standard Output Hide Invisibles Highlight: NoneStandard Input OnlyPrompts OnlyStandard...

  • 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,...

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