r/pythonhelp • • Jun 05 '22

Assistance with an output, please!

Hello, Can anyone help me with how to achieve this output:

Enter a number of seconds: 11730

Here is the time in Hours, Minutes, and Seconds:

Hours: 3.0

Minutes: 15.0

Seconds: 30.0

**We were provided this tip:

hours = yourVariable //3600

minutes=(yourVariable//60)%60

seconds=yourVariable%60

0 Upvotes

5 comments sorted by

1

u/CraigAT Jun 05 '22

Homework/Assignment? You should use the post flair.

What have you got so far?

You can use input() to get the input, int to make the input into an integer/number, then use the division and remainder/modulo equations you were given to calculate the amounts, then use print() to output your results.

2

u/Nonna1214 Jun 05 '22

Thank you! Your notes were helpful! I'm new here, just as I am new to coding- what is a post flair?

2

u/K1ngkai Jun 05 '22

It’s kinda of like a label for this post. If you see some of the posts it will say “homework”

1

u/AmongstYou666 Jun 05 '22 edited Jun 05 '22

sec = 11730
h = float(int(sec/3600))
m = float(int((sec-h*3600)/60))
r = sec-(h*3600)-(m*60)
print("Hours: {0:.1f} Minutes: {1:.1f} Seconds: {2:.1f}".format(h,m,r))

2

u/Nonna1214 Jun 06 '22

Thank you!