Homework 5: Mad Libs Calculator

File to submit: `mad_libs.ipynb + docx containing (trace table + reflection sentence (see Deliverables))

Overview

You will write a short Python program that collects a few pieces of information from the user, does a little arithmetic, and then uses a nested conditional to decide which "story" to print. This assignment pulls together everything you've worked on so far: variables, arithmetic expressions, conditionals, nested conditionals, and breaking a problem into logical steps.

You are not being graded on how elegant or clean your code is. You're being graded on whether the logic is correct and whether you can explain how it behaves — including on inputs that break it.

Requirements

Write a program called mad_libs.py that does the following, in order:

1. Collect input

Ask the user for:

2. Calculate a "Life Score"

Use this exact formula:

life_score: float = (age * 7) + len(name)

3. Handle bad input first

Before computing tiers, check whether age is negative.

4. Determine the tier (nested conditional required)

Using life_score, assign the user to one of the following tiers:

TierCondition
Rookielife_score < 50
Solid50 <= life_score < 100
Legendarylife_score >= 100

Nested check: If the tier is Legendary, add one more check inside that branch:

This inner check is the required nested conditional — it only makes sense to check it after we already know the person is in the Legendary branch.

5. Print the result

Print a Mad-Libs-style sentence using all the variables. For example:

Behold! NAME, protector of the ANIMAL kingdom, has achieved a Life Score of SCORE
and has been crowned... TIER!

(Exact wording is up to you — the sentence just needs to include the name, animal, score, and tier.)

Deliverables

Submit three things:

  1. mad_libs.py — your working script.

  2. Docx file containing:

    1. Trace table — hand-trace your program's execution for the two inputs below. For each input, track the value of every variable (name, animal, age, life_score, tier) at each step of the program, and write down the final printed output.

      Input Setnameanimalage
      A"Sam""otter"12
      B"Alexandria""falcon"20
    2. One written sentence explaining why the "Suspiciously Legendary" check needs to be nested inside the Legendary branch, rather than written as a separate, flat elif alongside Rookie/Solid/Legendary. 2. One written sentence explaining why the "Suspiciously Legendary" check needs to be nested inside the Legendary branch, rather than written as a separate, flat elif alongside Rookie/Solid/Legendary.

Grading Focus

You will primarily be assessed on:

Style and "cleanliness" of code are not graded here.