Lab Exam I (October 1, 2024)

solution

Lab Exam Policy

This is a closed-book exam! You may only have your cheat sheet and your IDE open. You may not use an internet browser to research the solution. There is only one programming question. Please read the question carefully. You will have 1 hour and 40 minutes to complete this exam. Note: Please leave time to submit your code using the following command on the tinman server:
sudo handin1301 e1 calendar.py
To transfer the file to tinman, you may use FileZilla OR the following procedure: Open a Terminal/Powershell Window. cd into the folder containing calendar.py. Then, type the following command (replace userid with your campusid):
sftp userid@tinman.cs.gsu.edu
you will be asked for your password; type it in (you may have to say "yes" to a question before password). once you see the sftp prompt, transfer the file as follows:
put calendar.py
Then make sure you exit the sftp program:
exit

calendar.py

Write a program that takes a date as input and outputs the date's season in the southern hemisphere. Your program must take as input from the user a string that represents the month and an integer to represent the day. For example, month = 'April' and day = 15.

The dates for each season in the southern hemisphere are:

  • Autumn: March 20 - June 20
  • Winter: June 21 - September 21
  • Spring: September 22 - December 20
  • Summer: December 21 - March 19
You may assume that the variables month and day already exist and will always have valid values. Your program should be able to handle all possible values for the month and day variables. Hint: Not all months require their days to be checked.
A sample run is shown below:
$ python calendar.py
Please enter the month: December
Please enter the day: 25
December 25 is summer in the southern hemisphere