Question

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 Output w/o PromptsFull Standard OutputAllShow Highlighted Only

Enter·number·of·seconds:279585↵
3·day(s),·5·hour(s),·39·minute(s),·and·45·second(s).↵
0 0
Add a comment Improve this question Transcribed image text
Answer #1
seconds = int(input("Enter number of seconds:"))

days = seconds // 86400
seconds %= 86400
hours = seconds // 3600
seconds %= 3600
minutes = seconds // 60
seconds %= 60

print("{} day(s), {} hour(s), {} minute(s), and {} second(s).".format(days, hours, minutes, seconds))



Add a comment
Know the answer?
Add Answer to:
Python Please help Write a program that asks the user to enter a number of 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, please help At one college, the tuition for a full-time student is $8,000 per semester....

    Python, please help At one college, the tuition for a full-time student is $8,000 per semester. It has been announced that the tuition will increase by 3 percent each year for the next 5 years. Write a program with a loop that displays the projected semester tuition amount for the next 5 years. The program should print out the result in the form In 1 year, the tuition will be $8002.3. In 2 years, the tuition will be $8103.2. In...

  • A cookie recipe calls for the following ingredients: • 1.5 cups of sugar • 1 cup...

    A cookie recipe calls for the following ingredients: • 1.5 cups of sugar • 1 cup of butter • 2.75 cups of flour The recipe produces 48 cookies with this amount of ingredients. Write a program that asks the user how many cookies they want to make and then displays the number of cups of each ingredient needed for the specified number of cookies in the following format: You need 5 cups of sugar, 3 cups of butter, and 7...

  • Write a program that asks the user to enter a number ofseconds.• There are...

    Starting Out with C++ (9th Edition)  Chapter 4, Problem 7PCWrite a program that asks the user to enter a number of seconds.• There are 86400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86400, the program should display the number of days in that many seconds.• There are 3600 seconds in an hour. If the number of seconds entered by the user is less than 86400, but is greater...

  • HELP IN JAVA: WHILE LOOP: Write a program that asks the user to enter a number...

    HELP IN JAVA: WHILE LOOP: Write a program that asks the user to enter a number of seconds. This number should be less than or equal to 32767 because that is the largest number pep8 can handle. Your program should then output the number of hours, minutes, and seconds on the planet of Crypton, where there are 64 seconds in a minute and 32 minutes in an hour.

  • using python Write a program that asks the user to enter a month (1 for January,...

    using python Write a program that asks the user to enter a month (1 for January, 2 for February, and so on) and then prints the number of days in the month. For February, print “28 or 29 days”. Enter a month: 5 30 days Do not use a separate if/else branch for each month. Use Boolean operators.

  • need this by tonight pls using python Write a program that asks the user to enter...

    need this by tonight pls using python Write a program that asks the user to enter a month (1 for January, 2 for February, and so on) and then prints the number of days in the month. For February, print “28 or 29 days”. Enter a month: 5 30 days Do not use a separate if/else branch for each month. Use Boolean operator

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

  • In Python, write a program that asks the user for a positive integer number. If the...

    In Python, write a program that asks the user for a positive integer number. If the user enters anything else, the program would ask the user to re-enter a number or enter -1 to quit. If it is a positive number, the program then prints out a multiplication table that goes up to that number. For example, if the user enters 10, the output would look something like this. https://www.vectorstock.com/royalty-free-vector/multiplication-table-on-white-background-vector-2721686

  • Write a program that uses String method regionMatches to compare two strings input by the user....

    Write a program that uses String method regionMatches to compare two strings input by the user. The program should prompt the user to enter two strings, the starting index in the first string, the starting index in the second string, and the number of characters to be compared. The program should print whether or not the strings are equal, (Ignore the case of the characters during comparison.) 四SAMPLE RUN #1: java StringCompare Highlight: None D Show Highlighted Only Interactive Session...

  • JAVA Write a complete program that prompts the user to provide a time span expressed in...

    JAVA Write a complete program that prompts the user to provide a time span expressed in seconds from keyboard, gets the input, then converts the seconds to the time expressed in days, hours, and minutes and seconds in that order, and output them in a readable format of your choice. For example, suppose the input for seconds is 3662, your program should figure out that it is equivalent to 0 day, 1 hour, 1 minute and 2 seconds. So your...

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