Write a program that reads a number of seconds and prints it in form : mins and second, e.g. 200 seconds are printed as 3 mins and 20 seconds. In python
Answers
Answered by
28
Program:
To read a number in seconds and displayed as minutes and seconds format.
time_in_secs = float (input(“Time in seconds:”))
time_in_secs = time_in_secs %
time_in_secs % = 3600
mins = time_in_secs
time_in_secs % = 60
secs = time_in_secs
print (“mins , secs: ->%d, %d” % (mins,secs))
Explanation:
Step 1: Get input on ‘time_in_secs_ as input of float data type using input() method.
Step 2: Then, the time_in_secs should be converted into 24 h format.
Step 3: By using modulo operator, the time_in_sec later changed as minutes format.
Step 4: Assign time_in_secs as ‘mins’
Step 5: Convert time_in_secs (1 min = 60s) in seconds format.
Step 6: Assign time_in_secs to secs.
Step 7: Print the minutes and seconds (mins, secs) as output.
Similar questions
Social Sciences,
6 months ago
Math,
6 months ago