r/pythonhelp • u/Nonna1214 • 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
1
u/AmongstYou666 Jun 05 '22 edited Jun 05 '22
sec = 11730h = 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
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.