Build a Movie Ticket Picker in Python
Build a Python ticket picker that checks age, price, and budget.
Introduction
30 Second Summary
Choosing a cinema ticket sounds simple until age rules meet spending limits at the counter. A single birthday or one dollar can change the answer.
In this project, you will build a fictional cinema ticket picker with Python that selects a ticket from a customer's age. A whole-dollar budget drives its affordability message.
What You'll Build
You enter an age plus a budget into the terminal to see a fictional ticket type, its price, and a clear verdict on whether the customer can buy it.
By the end of this project, you'll have:
- An age-based ticket picker that displays a Child Ticket, Standard Ticket, or Senior Ticket with its fictional price.
- An affordability check that shows whether money remains, the budget is exact, or more money is needed.
- A set of boundary tests using ages 12, 13, 64, and 65 to prove that each customer reaches the intended branch.
- Secret Mission: Add a fictional Tuesday discount before the program checks whether the ticket is affordable.
Are there any prerequisites?
You need a Mac with administrator access. You also need Visual Studio Code installed.
The project guides you through installing Python 3.15.0 plus the Python extension for Visual Studio Code.
Before We Start
First, lock in why you want to build a fictional cinema ticket picker. This purpose gives every comparison and conditional branch a clear job.
Set Up Python and Run Your First File
Visual Studio Code can edit your ticket picker. A Python interpreter executes the instructions you write.
In this step, you'll connect Python 3.15.0 to your editor with the Python extension for Visual Studio Code. You'll prove the setup works by running your first Python file.
In this step, get ready to:
- Install Python 3.15.0 with its certificate setup.
- Connect Visual Studio Code to the Python interpreter through Microsoft's extension.
- Create your project file and run its welcome message.
Install the Python interpreter
The interpreter turns the instructions in a Python file into actions on your Mac. Checking the current version first shows which installation path fits your machine.
- Press Cmd+Space (macOS) or the Windows key (Windows) to open your search bar.
- Type Terminal and press Enter to open it.
You'll see a Terminal window where your Mac can accept commands.
- Check which Python version your Mac can find by running this command:
python3 --version
What does this command check?
The python3 command asks your Mac to use Python 3. The --version option reports the interpreter version without starting a program.
✔️ I see the required version
Your output matches Python 3.15.0. The required interpreter is ready for its certificate setup.
ⓧ I see an older version
Administrator approval can feel sensitive. This permission lets the installer place Python on your Mac.
- Open the Python.org macOS downloads page in your browser.
- Download the macOS installer for Python 3.15.0.
The downloaded .pkg file appears in your Downloads folder.
- Open the downloaded .pkg installer from your Downloads folder.
The standard macOS installer opens with the installation details.
- Keep the standard installation options.
- Select Install.
macOS requests administrator approval before copying the interpreter into Applications.
- Enter your administrator credentials when macOS requests approval.
The final check uses a fresh terminal so the shell can discover the newly installed interpreter.
ⓧ Command not found
Administrator approval can feel sensitive. This permission lets the installer place Python on your Mac.
- Open the Python.org macOS downloads page in your browser.
- Download the macOS installer for Python 3.15.0.
The downloaded .pkg file appears in your Downloads folder.
- Open the downloaded .pkg installer from your Downloads folder.
The standard macOS installer opens with the installation details.
- Keep the standard installation options.
- Select Install.
macOS requests administrator approval before copying the interpreter into Applications.
- Enter your administrator credentials when macOS requests approval.
The final check uses a fresh terminal so the shell can discover the newly installed interpreter.
Python uses certificates when it connects securely to services on the internet. The installer includes a completion script that prepares those certificates.
- Select Finder from your Mac's Dock.
- Select Applications in the Finder sidebar.
You'll see the Python folder at /Applications/Python 3.15/.
- Open the Python 3.15 folder.
- Double-click Install Certificates.command.
That completes Python's certificate setup. The terminal output ends with Successfully installed certifi followed by update complete.
Installer or certificate step stuck?
Confirm that the macOS account approving the installer has administrator access.
If the certificate completion text is missing, return to /Applications/Python 3.15/ and double-click Install Certificates.command again.
Help me finish the Python installation on my Mac.
Connect Python to Visual Studio Code
The Python extension adds interpreter selection and file-running controls to Visual Studio Code. Selecting the interpreter tells the editor which Python installation should execute your file.
- Press Cmd+Space (macOS) or the Windows key (Windows) to open your search bar.
- Type Visual Studio Code and press Enter to open it.
You'll see the Visual Studio Code editor window.
- Select the Extensions view in the Activity Bar.
- Enter Python in the extension search box.
The search results show extensions that support Python development.
- Select the Python extension for Visual Studio Code published by Microsoft.
Its details page lists Microsoft as the publisher.
- Select Install.
The extension now shows as installed in Visual Studio Code.
- Press Command+Shift+P to open the Command Palette.
You'll see a searchable list of Visual Studio Code commands.
- Choose Python: Select Interpreter.
Visual Studio Code lists the Python interpreters it can find on your Mac.
- Select Python 3.15.0.
The selected interpreter now uses Python 3.15.0 for files in your editor.
Can't find the interpreter?
Quit Visual Studio Code after the Python installation finishes. Reopen it so the extension can refresh its interpreter list.
Confirm that you selected the extension published by Microsoft if the interpreter command is missing.
Help me connect Python to Visual Studio Code.
Create and run your first file
A folder opened in Visual Studio Code becomes a workspace for related files. The .py extension tells the editor to treat your file as a Python program.
- Select File in the Visual Studio Code menu bar.
- Select Open Folder....
You'll see the macOS folder selection window.
- Select your Desktop as the folder location.
- Select New Folder.
A field opens for the new folder's name. Visual Studio Code may ask whether you trust the folder after it opens.
- Enter movie-ticket-picker as the folder name.
- Select Open.
Your new folder opens as the active workspace.
- Select Yes, I trust the authors if the Workspace Trust prompt appears.
The Explorer sidebar now shows movie-ticket-picker as the open folder.
- Select New File... in the Explorer sidebar.
- Enter movie_ticket_picker.py as the file name.
The new movie_ticket_picker.py file opens in the editor.
- Add the welcome message to movie_ticket_picker.py by pasting this code:
print("Movie Ticket Picker")
What does this code do?
- The print() call sends a value to the terminal.
- The "Movie Ticket Picker" string literal holds the exact message that Python prints.
- Save movie_ticket_picker.py with Cmd+S (macOS) or Ctrl+S (Windows).
The Explorer now lists the saved movie_ticket_picker.py file inside movie-ticket-picker.
- Select Terminal in the Visual Studio Code menu bar.
- Select New Terminal.
A fresh terminal opens inside the movie-ticket-picker workspace.
Before you run the check, which Python version do you expect this fresh terminal to report?
- Confirm the interpreter version by running this command:
python3 --version
What does this check prove?
This check confirms that the fresh Visual Studio Code terminal can find the newly installed interpreter. It also confirms that your shell is using the required version.
You'll see Python 3.15.0 in the terminal.
Before you run the file, what message do you expect the terminal to print?
- Select Run Python File using the play button at the top right of the editor.
You have your first working Python file. The terminal prints Movie Ticket Picker.
✔️ Awesome, I've got everything!
Your saved file runs with Python 3.15.0 and prints the welcome message.
ⓧ I'd like to double check the full code
Compare your complete movie_ticket_picker.py file with this reference.
print("Movie Ticket Picker")
Version or welcome message missing?
If the terminal reports an older version, quit Visual Studio Code after installation. Reopen the editor before creating another fresh terminal.
If the run button is missing, confirm that movie_ticket_picker.py is open. Confirm that the Microsoft Python extension is installed.
Help me run my first Python file in Visual Studio Code.
Your editor can now execute the ticket picker with the correct interpreter. Next, you'll ask for an age and use conditional branches to choose a ticket.
Pick a Ticket by Age
Your welcome message proves your file runs in Visual Studio Code. Every customer still gets the same response.
This step turns the customer's age into a ticket choice with conditional logic. The picker will select one fictional ticket type plus price for each age range.
In this step, get ready to:
- Collect the customer's age as a whole number.
- Use three branches to select a fictional ticket type plus price.
- Prove the age boundaries with the required test values.
Collect the customer's age
The input() function pauses the program to collect an answer. The int() function converts that answer into a whole number for numeric comparisons.
- Select movie_ticket_picker.py in the VS Code sidebar.
- Find this existing line:
print("Movie Ticket Picker")
What does this line do?
The print() call displays the program's title. It confirms that Python has started the correct file.
- Add the age prompt below the existing line with one blank line between them so the top of movie_ticket_picker.py matches this reference:
print("Movie Ticket Picker")
age = int(input("Enter the customer's age: "))
How Does the Age Prompt Work?
- The input() call displays the prompt before reading the customer's response.
- The int() call converts the response from text into a whole number.
- The age variable stores that number for the ticket decision.
- Save movie_ticket_picker.py.
- Select Run Python File at the top right.
- Enter 13 when the age prompt appears.
You'll see Enter the customer's age: in the terminal. After you enter 13, the program stores the age before returning control to the terminal.
Age Prompt Missing?
Confirm that the movie_ticket_picker.py tab is active. Save the file before selecting Run Python File again.
Use digits for the age because int() expects a valid whole number.
help me troubleshoot my Python age prompt
Choose a ticket with branches
An if, elif, plus else chain checks conditions from top to bottom. Python runs the first matching branch.
Indented variables store the ticket selected by that branch. Four spaces keep each assignment inside its intended branch.
- Place your cursor below the line that defines age.
- Add the ticket branches plus output lines by copying this code:
if age <= 12:
ticket_type = "Child Ticket"
ticket_price = 8
elif age >= 65:
ticket_type = "Senior Ticket"
ticket_price = 9
else:
ticket_type = "Standard Ticket"
ticket_price = 12
print("Ticket type:", ticket_type)
print("Price: $", ticket_price, sep="")
What Does This Code Do?
- The if age <= 12: branch selects a Child Ticket for ages up to 12.
- The elif age >= 65: branch selects a Senior Ticket from age 65.
- The else: branch selects a Standard Ticket for every remaining age.
- The ticket_type variable stores the selected ticket label.
- The ticket_price variable stores its fictional whole-dollar price.
- The final print() calls display both selected values.
- Save movie_ticket_picker.py.
Before you run the picker, do you think an age alone can prove that the customer can afford the selected ticket?
- Select Run Python File at the top right.
- Enter 13 at the age prompt.
You'll see Standard Ticket with a price of $12. The program stops without asking what the customer can spend.
That shortfall is intentional. Age can select a ticket, but it cannot prove affordability.
Ticket Result Missing?
Compare the indentation inside each branch. Every assignment beneath if, elif, or else needs four spaces.
Check that elif plus else line up with if.
help me fix my age branches
✔️ Awesome, I've got everything!
Your saved file now collects an age before selecting a fictional ticket type plus price.
ⓧ I'd like to double check the full code
This is the complete movie_ticket_picker.py file at this point.
print("Movie Ticket Picker")
age = int(input("Enter the customer's age: "))
if age <= 12:
ticket_type = "Child Ticket"
ticket_price = 8
elif age >= 65:
ticket_type = "Senior Ticket"
ticket_price = 9
else:
ticket_type = "Standard Ticket"
ticket_price = 12
print("Ticket type:", ticket_type)
print("Price: $", ticket_price, sep="")
How Does the Full File Flow?
The file collects the age before checking the ticket conditions. It prints the values assigned by the single matching branch.
Test the age boundaries
Boundary testing checks the exact values where a program changes branches. Ages 12, 13, plus 65 prove both age cutoffs.
Before these runs, which ticket label do you expect for each age?
- Select Run Python File at the top right.
- Enter 12 at the age prompt.
You'll see Ticket type: Child Ticket plus Price: $8.
- Select Run Python File again.
- Enter 13 at the age prompt.
You'll see Ticket type: Standard Ticket plus Price: $12.
- Select Run Python File one more time.
- Enter 65 at the age prompt.
You'll see Ticket type: Senior Ticket plus Price: $9.
Strong result. Each boundary now reaches exactly one ticket branch.
Your picker now turns a customer's age into a ticket recommendation. Next, you'll check whether the customer can afford that ticket.
Check Whether the Ticket Is Affordable
Your age branches now choose a fictional ticket from the customer's age. A recommendation still falls short when the selected price exceeds the customer's budget.
This step adds a whole-dollar budget. A Python comparison then decides whether the selected ticket is affordable.
In this step, get ready to:
- Collect the customer's whole-dollar budget.
- Compare the budget with the selected ticket price.
- Run the affordability decision with several budgets.
Capture the customer's budget
The selected ticket price gives your program one side of the affordability decision. The customer's budget supplies the other side.
- Place the new input below the price output in movie_ticket_picker.py by adding this line:
budget = int(input("Enter the whole-dollar budget: $"))
How does the budget input work?
- The input() function displays the budget prompt.
- The int() function converts the customer's response into a whole number.
- The budget variable keeps that number ready for the affordability decision.
- Save movie_ticket_picker.py.
- Select Run Python File from the top-right corner of VS Code.
You'll see the age prompt in the terminal.
- Enter 30 at the age prompt.
You'll see the new whole-dollar budget prompt after the Standard Ticket price.
- Enter 12 at the budget prompt.
You'll return to the terminal prompt after entering the budget. This confirms that Python collected the new value as a whole number.
Does the script stop at the budget input?
Enter digits without a dollar sign because int() expects a whole-number response. Check that the quotation marks and parentheses match the code above.
Ask for help if the prompt still fails: help me fix the budget input in my Python ticket picker
Create the affordability branches
The budget and ticket price are both whole numbers. The >= operator can now test whether the customer has enough money.
- Place the affordability decision below the budget input by adding this code:
if budget >= ticket_price:
print("The customer can buy this ticket.")
else:
print("The customer cannot buy this ticket yet.")
How does the comparison choose a branch?
- The budget >= ticket_price condition tests whether the customer has enough money for the selected ticket.
- The if branch prints the affordable message when the comparison is true.
- The else branch prints the shortfall message when the comparison is false.
- The four spaces before each print() line show which statement belongs to each branch.
- Save movie_ticket_picker.py.
Before you test the comparison, which branch do you think an exact budget of 12 uses?
- Select Run Python File in the top-right corner.
- Enter 30 for the customer's age.
- Enter 12 for the whole-dollar budget.
You'll see Standard Ticket with Price: $12. The final line says The customer can buy this ticket..
- Select Run Python File again.
- Enter 30 for the customer's age.
- Enter 11 for the whole-dollar budget.
The final line now says The customer cannot buy this ticket yet.. You have run both sides of the affordability decision.
Does the wrong branch run?
Check that the condition uses budget >= ticket_price in that order. Confirm that both print() lines have four spaces before them.
Use this prompt for focused help: help me debug the affordability branches in my Python ticket picker
Test the decision boundary
You have tested a budget at the ticket price and a budget below it. One case remains at the other side of the boundary.
Before you run the next check, do you think a larger budget produces a more detailed result than an exact budget?
- Select Run Python File again.
- Enter 30 for the customer's age.
- Enter 20 for the whole-dollar budget.
You'll see The customer can buy this ticket. again. The larger budget receives the same result as the exact budget.
What did this test expose?
The current condition answers one question: does the customer have enough money? Both exact and larger budgets make that comparison true.
This is the intended limitation of the two-branch check. Your next step can separate extra money from an exact budget.
✔️ Awesome, I've got everything!
Great work. Save movie_ticket_picker.py with the working budget comparison.
ⓧ I'd like to double check the full code
Compare your complete movie_ticket_picker.py file with this version.
print("Movie Ticket Picker")
age = int(input("Enter the customer's age: "))
if age <= 12:
ticket_type = "Child Ticket"
ticket_price = 8
elif age >= 65:
ticket_type = "Senior Ticket"
ticket_price = 9
else:
ticket_type = "Standard Ticket"
ticket_price = 12
print("Ticket type:", ticket_type)
print("Price: $", ticket_price, sep="")
budget = int(input("Enter the whole-dollar budget: $"))
if budget >= ticket_price:
print("The customer can buy this ticket.")
else:
print("The customer cannot buy this ticket yet.")
That closes the biggest gap: your picker now warns when the selected ticket exceeds the customer's budget. Next up, you'll give exact budgets and extra money their own results.
Handle Exact Budgets and Change
Your Python picker can now compare a customer's budget with the selected ticket price. An exact budget currently prints the same message as a larger budget.
This step gives that hidden boundary its own branch. Arithmetic will also show the money left or the money still needed.
In this step, get ready to:
- Separate larger budgets from exact budgets.
- Calculate the dollar difference for non-exact budgets.
- Test all three Standard Ticket budget boundaries.
Separate the three budget outcomes
The order of your comparison operators controls which budget reaches each branch. The first true condition chooses the message.
- In movie_ticket_picker.py, find the budget check at the bottom of the file.
- Compare the current budget check with this reference:
if budget >= ticket_price:
print("The customer can buy this ticket.")
else:
print("The customer cannot buy this ticket yet.")
What Does the Current Check Do?
The condition budget >= ticket_price accepts every budget that meets or exceeds the price. This groups exact budgets with larger budgets.
- Replace that entire budget check with the three-branch version below:
if budget > ticket_price:
print("The customer can buy this ticket.")
elif budget == ticket_price:
print("The customer can buy this ticket with an exact budget.")
else:
print("The customer cannot buy this ticket yet.")
How Do These Branches Split the Boundary?
- The budget > ticket_price condition catches budgets above the price.
- The budget == ticket_price condition catches an exact match.
- The else branch catches budgets below the price.
Before you run this version, predict which branch an exact budget will reach.
- Save movie_ticket_picker.py.
- Select Run Python File in the top-right toolbar.
- Enter 30 when the age prompt appears.
- Enter 12 when the budget prompt appears.
You will see The customer can buy this ticket with an exact budget. The equality branch now makes the boundary visible.
Exact Budget Reaching the Wrong Branch?
- Check that the first condition uses > without an equals sign.
- Keep the budget == ticket_price condition inside the elif branch.
- Check that each indented line begins with four spaces.
Ask for help with the branch order.
Calculate money left or needed
The three branches identify the correct outcome. Two subtraction expressions now turn that outcome into a useful dollar amount.
- Replace the budget check you just edited with this completed version:
if budget > ticket_price:
money_left = budget - ticket_price
print("The customer can buy this ticket.")
print("Money left: $", money_left, sep="")
elif budget == ticket_price:
print("The customer can buy this ticket with an exact budget.")
else:
money_needed = ticket_price - budget
print("The customer cannot buy this ticket yet.")
print("More money needed: $", money_needed, sep="")
What Does This Code Calculate?
- The money_left variable stores the result of budget - ticket_price for a larger budget.
- The equality branch needs no subtraction because the difference is zero.
- The money_needed variable stores the result of ticket_price - budget for a shortfall.
- The sep="" argument keeps each dollar sign beside its amount.
- Save movie_ticket_picker.py.
- Select Run Python File in the top-right toolbar.
- Enter 30 when the age prompt appears.
- Enter 20 when the budget prompt appears.
You will see Money left: $8. The picker now shows the result of subtracting the Standard Ticket price from the budget.
Seeing the Wrong Dollar Amount?
- Check that money_left uses budget - ticket_price.
- Check that money_needed uses ticket_price - budget.
- Keep each calculation indented inside its matching branch.
Ask for help with the subtraction results.
✔️ Awesome, I've got everything!
Your three budget branches are complete. Double check that you saved movie_ticket_picker.py.
ⓧ I'd like to double check the full code
Compare your complete movie_ticket_picker.py file with this reference.
print("Movie Ticket Picker")
age = int(input("Enter the customer's age: "))
if age <= 12:
ticket_type = "Child Ticket"
ticket_price = 8
elif age >= 65:
ticket_type = "Senior Ticket"
ticket_price = 9
else:
ticket_type = "Standard Ticket"
ticket_price = 12
print("Ticket type:", ticket_type)
print("Price: $", ticket_price, sep="")
budget = int(input("Enter the whole-dollar budget: $"))
if budget > ticket_price:
money_left = budget - ticket_price
print("The customer can buy this ticket.")
print("Money left: $", money_left, sep="")
elif budget == ticket_price:
print("The customer can buy this ticket with an exact budget.")
else:
money_needed = ticket_price - budget
print("The customer cannot buy this ticket yet.")
print("More money needed: $", money_needed, sep="")
Use this full-file view to check the branch order. Confirm that each indented line sits beneath the correct condition.
Test every budget boundary
Boundary testing checks values where the program changes direction. A Standard Ticket gives all three budget branches one fixed price to compare.
Before you run these tests, predict which branch each budget will reach.
- Select Run Python File in the top-right toolbar.
- Enter 30 when the age prompt appears.
- Enter 20 when the budget prompt appears.
You will see the affordable message followed by Money left: $8.
- Select Run Python File again.
- Enter 30 when the age prompt appears.
- Enter 12 when the budget prompt appears.
You will see The customer can buy this ticket with an exact budget. Only the equality branch runs.
- Select Run Python File one more time.
- Enter 30 when the age prompt appears.
- Enter 8 when the budget prompt appears.
You will see the shortfall message followed by More money needed: $4.
One of the Boundary Tests Looks Wrong?
- Confirm that age 30 selects a Standard Ticket priced at 12.
- Check that the budget branches appear in the order >, ==, and else.
- Rerun each test after saving the latest version of movie_ticket_picker.py.
Ask for help comparing your three test results.
That is the core picker complete. Every budget boundary now produces a specific result with the relevant dollar amount.
Secret mission
Add a Tuesday Discount
Your ticket picker currently uses the same fictional price every day. In this mission, you will normalize a day entry before applying a Tuesday discount that changes the affordability decision.
Clean Up Your Resources
Clean Up Your Resources
Your ticket picker runs entirely on your Mac, so there are no ongoing service costs. Decide whether to keep the folder available, pause your work, or delete it entirely.
Resources you used:
- Local movie-ticket-picker folder containing movie_ticket_picker.py.
Keep everything running
No action needed. Choose this if you want to keep testing ticket ages, budgets, or discount days.
- Keep the movie-ticket-picker folder on your Mac.
- Your saved movie_ticket_picker.py file remains ready for more boundary tests.
Pause - I'll come back to this later
Pause your work without removing any files. The Python script does not keep a server running after it finishes.
- Save movie_ticket_picker.py in Visual Studio Code.
- Close Visual Studio Code when you are ready to stop.
- Reopen the movie-ticket-picker folder when you want to continue.
Delete - I don't want to use this again
Remove the local project folder if you no longer need your ticket picker. First, confirm that the terminal is inside the correct folder.
- Return to the terminal that ran movie_ticket_picker.py.
- Confirm the terminal location by running this command:
pwd
What Does This Command Do?
This command prints the terminal's current folder path.
You should see a path ending in /movie-ticket-picker.
Seeing a Different Folder?
Stop before deleting anything if the path ends with a different folder name. Help me safely find the movie-ticket-picker folder from my terminal.
Deleting this folder permanently removes your script. Your installed development tools remain available for future projects.
- Move to the parent folder and delete movie-ticket-picker by running these commands:
cd ..
rm -rf movie-ticket-picker
ls
What Do These Commands Do?
- The first command moves the terminal to the folder that contains movie-ticket-picker.
- The second command permanently removes movie-ticket-picker with everything inside it.
- The final command lists the remaining folders so you can verify the deletion.
You should no longer see movie-ticket-picker in the terminal output.
Still See the Project Folder?
Check that the folder name is exactly movie-ticket-picker. Confirm that the terminal moved to its parent folder before trying again.
Help me verify why the project folder was not deleted.
Nice Work!
Nice Work!
You did it! Your Python ticket picker now selects a fictional ticket by age. It applies a Tuesday discount before showing whether the customer has enough money.
You've learned how to:
- Build a complete command-line ticket picker in Visual Studio Code that collects customer details through input().
- Control ticket selection and affordability messages with if, elif, else, <=, >, >=, and ==.
- Prove each decision boundary by testing ages 12, 13, 64, and 65 alongside budgets above, equal to, or below the selected price.
- Secret Mission: Normalize a day entered by the customer. Apply a fictional Tuesday discount before the affordability decision.
Ready to quiz yourself?