Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[BASIC] Time conversion with hours and minutes
#1
Brick 
Incredibly simple Python script to convert hours and minutes and add N minutes then output it in a formatted manner.

Code:
hours = int(input("Enter the hour: "))
minutes = int(input("Enter the minute: "))
n = int(input("Enter the extra minutes to be added: "))

hrsToMins = int((hours * 60) + int(minutes % 60)) # Hours to minutes conversion
print(int((hrsToMins + minutes) / 60), "hr", int((minutes + n) % 60), "m")


Program output when ran:
Code:
Enter the hour: 3
Enter the minute: 55
Enter the extra minutes to be added: 25
4 hr 20 m

You could build on to this seemingly simple program, but it is very basic in how it operates.
Discord moderator
[-] The following 1 user Likes Muted's post:
  • admin
Reply
#2
Nice thread we can collaborate to make Mega python basics thread.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)