Python Forum
how to think like a computer scientist
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to think like a computer scientist
#7
(Jan-05-2018, 06:39 AM)broke_university_student Wrote:
current_time_str = input("What is the current time? ")
waiting_time_str = input("How many hours do you have to wait? ")

current_time_int = int(current_time_str)
waiting_time_int = int(waiting_time_str)

hours = current_time_int + waiting_time_int

timeofday = hours % 24

print(timeofday)
This works. However, I am unsure on what to do with the "am" and "pm".

I think I found a solution,

current_datetime = input("What is the current time (in hours)? ")
meridien = input('Enter am/pm: ')
waiting_time = input("How many hours do you have to wait? ")

current_time_int = int(current_datetime)
waiting_time_int = int(waiting_time)

hours = current_time_int + waiting_time_int

timeofday = hours % 24


print(timeofday,meridien)
buran write Dec-03-2020, 08:38 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply


Messages In This Thread
RE: how to think like a computer scientist - by Antonioney - Dec-03-2020, 08:19 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020