Nov-01-2018, 07:00 PM
Hi,
In the below code(Code_1), please help me understand the logic of dividing minutes and seconds by 10. The second program(Code_2) also gives the same result. But the below program's logic, I'm unable to understand.
Code_1
seconds=eval(input("Please enter the number of seconds: "))
hours=seconds//3600
seconds=seconds%3600
minutes=seconds//60
seconds=seconds%60
print(hours, ":", sep="", end="")
tens=minutes//10
ones=minutes%10
print(tens, ones, ":", sep="", end="")
tens=seconds//10
ones=seconds%10
print(tens, ones, sep="")
Code_2
seconds=eval(input("Please enter the number of seconds: "))
hours=seconds//3600
seconds=seconds%3600
minutes=seconds//60
seconds=seconds%60
print(hours,":",minutes,":",seconds)
In the below code(Code_1), please help me understand the logic of dividing minutes and seconds by 10. The second program(Code_2) also gives the same result. But the below program's logic, I'm unable to understand.
Code_1
seconds=eval(input("Please enter the number of seconds: "))
hours=seconds//3600
seconds=seconds%3600
minutes=seconds//60
seconds=seconds%60
print(hours, ":", sep="", end="")
tens=minutes//10
ones=minutes%10
print(tens, ones, ":", sep="", end="")
tens=seconds//10
ones=seconds%10
print(tens, ones, sep="")
Code_2
seconds=eval(input("Please enter the number of seconds: "))
hours=seconds//3600
seconds=seconds%3600
minutes=seconds//60
seconds=seconds%60
print(hours,":",minutes,":",seconds)