Programming Examples

Python program that reads a number of seconds and prints it in form mins and seconds


Write a program that reads a number of seconds and prints it in form : mins and seconds, e.g., 200 seconds are printed as 3 mins and 20 seconds.

[Hint. use // and % to get minutes and seconds]

Solution

totalSecs = int(input("Enter seconds: "))

mins = totalSecs // 60
secs = totalSecs % 60

print(mins, "minutes and", secs, "seconds")
Output

Enter seconds: 200

3 minutes and 20 seconds

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz