Lab 2 – Branching

Write a Python program that gets user input and branching.

Lab Description

The Chinese Zodiac is based on a 12-year cycle. Each year within a 12-year period is represented by a different animal. The first year (i.e. year 0) is the year of the monkey, with the second year (i.e. year 1) being the year of the rooster. This continues until the 13th year (i.e. year 12), which goes back to monkey. Write a program that prompts the user to enter a year and outputs the animal in the Chinese Zodiac for the year. There is an image to show the Chinese Zodiac signs and some of the years. Note that you will need it to work for any year, not just the ones listed in the image below.

Steps

  1. In PyCharm (Community Edition), open your existing ITP115 project.
  2. Under the Labs directory, create a new Python file called lab2_last_first.py where last is your last/family name and first is your preferred first name. Use all lowercase letters.

This content is protected and may not be shared, uploaded, or distributed.

ITP 115 2022-08-20

  1. At the top of the file, put comments in the following format and replace the name, email, and section with your actual information:
  2. # ITP 115, Fall 2022
  3. # Section: number or nickname
  4. # Lab 2
  5. Ask the user for the year. Make sure to convert the year to an integer. The user input is shown in green text.
  6. Enter year: 2000
  7. Use the modulus operator to get a value between 0 and 11 and store it in a

variable.

  1. Use branching to map the number to a specific animal and store it in a variable.
  2. Print a message with the year and animal using the appropriate variables.

2000 is the Year of the Dragon.

  1. Upload the Python file named lab2_last_first.py to your Blackboard section: o On Blackboard, navigate to the appropriate lab item.
    o Click on the specific item for this lab.
    o Click on the Browse Local Files button and select the file.

o Click the Submit button.

Additional Notes

  • Each lab is worth 1 point. To earn the point, make sure your program runs correctly and that you submit it correctly.

Sample Output

Enter year: 2000
2000 is the Year of the Dragon.

 


    Customer Area

    Make your order right away

    Confidentiality and privacy guaranteed

    satisfaction guaranteed