Lab 2
Lab 2
Question 1:
Write a program that reads two times in military format (0900, 1730) and prints the number of hours
and minutes between the two times. Assume the time difference is within 24 hours. Here is a sample
run. User inputs are in red color and the output is in green color.
Output:
Hints: Use input() statement to get an input from user, for example
Please note the if statements should deal with scenarios other than the example shown above:
Scenario 1: the hours in second time is greater than hours in the first time, but minutes is less. For
example
Output:
Scenario 2: the hours in second time is less than hours in the first time, but minutes is greater. For
example
Output:
Scenario 3: the hours in second time is less than hours in the first time, but minutes is also less. For
example
Output:
Please test run your program with all the scenarios and upload the file on Moodle.
Question 2 (Optional):
Write a program that asks the user to enter a month (1 for January 2 for February, and so on) and then
prints the number of days in the month. For February, print “28 or 29 days”.
Sample run:
Enter a month: 5
5 is May and it has 30 days