Functions & Abstraction
Variables & String Methods
Primitive Data Types and Casting
Logic & Conditionals
Final Jeopardy
100

This reason for using functions focuses on how code is contained in a named block such as main() to organize execution rather than placing instructions loose at the top level.

What is Encapsulation?

100

If you prompt a user with input() without doing this step, the provided data is lost and cannot be referenced in subsequent code.

What is assigning/storing the result in a variable?

100

int, float, str, and bool represent four fundamental examples of these in Python.

What are data types?

100

These three logical operators are used to construct complex Boolean expressions for range checking and multi-condition validity checks.

What is AND, OR, or NOT?

100

A local theater needs a function to handle ticket purchases. Write a Python program with a function named process_ticket that completes the following steps:

  1. Parameters: Accepts a raw name string (name_input) and an age integer (age).

  2. String Cleaning: Cleans name_input by removing leading/trailing whitespace and converting it to Capitalized Title Case (e.g., "  jANE dOE " becomes "Jane Doe").

  3. Conditionals & Logic:

    • If age is under 12 or 65 and older, assign a ticket price of $10.

    • Otherwise, assign a ticket price of $15.

  4. Return Value: Returns a formatted string formatted as: "[Cleaned Name]: $[Price]".

Finally, write a main() function that prompts the user for their name and age using input(), performs any necessary type casting, calls process_ticket(), and prints the result.


def process_ticket(name_input, age):

    clean_name = name_input.strip().title()

    if age < 12 or age >= 65:

        price = 10

    else:

        price = 15

    return f"{clean_name}: ${price}"

def main():

    raw_name = input("Enter your name: ")

    raw_age = input("Enter your age: ")

    age_int = int(raw_age)

    result = process_ticket(raw_name, age_int)

    print(result)

main()

200

The distinction between writing the code that defines a function and this action, which actually triggers the function to run.

What is calling (or invoking) a function?

200

Methods such as .strip(), .lower(), and .upper() are frequently used on user inputs to perform this essential task before processing.

What is defensive input cleaning?

200

This process converts a value from one data type to another, such as turning "42" into 42.

What is type casting?

200

Which conditional keyword would you use in a chained conditional program that has only 1 (a mutually exclusive) outcome?

What is elif?

300

These variables in a function definition allow it to accept dynamic inputs rather than using fixed or hardcoded values.

What are parameters?

300

Regardless of whether a user enters numbers or text, this is always the default data type returned by Python's built-in input() function.

What is a String (str)?

300

This specific error occurs if you attempt to cast a string like "hello" into an integer using int("hello").

What is a ValueError?

300

Which Boolean operator is NOT listed here:

==, >=, <=, >, <

What is != ?

400

This statement sends data from inside a function back to the caller; if omitted, the function implicitly outputs None.

What is a return statement?

400

The single equals sign (=) performs this operation, whereas the double equals sign (==) performs this operation.

What is assignment vs. equality comparison?

400

You must cast string inputs to this specific numeric data type if you plan to accept inputs containing decimal places.


What is float?

400

These conditional structures place at least 1 if block inside another if or elif block, expanding total outcome paths into a multi-tier branching logic tree.

What are nested conditionals?

500

This variable is created within a function and can only be accessed within that function, separating what happens inside a function from the calling scope.

What is local scope?

500

If a program executes 

user_input = "  alice_smith  ".strip().title().replace("_", " ")

this is the final value and data type stored in user_input.

What is "Alice Smith"

500

A string that allows the programmer to display the value of variables within a string using { } and to perform in-line calculations.

What is an f-string/formatted string?

500

In nested conditionals, the initial outer condition acts as this, verifying general criteria before allowing execution to proceed to complex inner logic.

What is a "gatekeeper" conditional?

M
e
n
u