# write some code that spits out end times for student lessons. def CalcEndTime(time): time = time.split(':') hour = int(time[0]) minute = int(time[1]) ClassTime = 40 minute = int(minute) + ClassTime if minute >= 60: minute = minute - 60 hour = int(hour) + 1 if hour >= 24: hour = int(hour) - 24 if minute == 0: minute = "00" EndTime = str(hour) + ":" + str(minute) return EndTime classes = input("Number of Classes: ") log = [] while int(classes) > 0: StartTime = input("Start Time: ") EndTime = CalcEndTime(StartTime) pair = [StartTime, EndTime] log.append(pair) #print(StartTime + " - " + EndTime) classes = int(classes) - 1 print(" ") count = 1 for item in log: print("Class " + str(count) + ": " + item[0] + " - " + item[1]) count = int(count) + 1
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question