0
0
Pythonprogramming~15 mins

If statement execution flow in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
If Statement Execution Flow
📖 Scenario: You are helping a small shop decide what message to show customers based on the amount they spend.
🎯 Goal: Build a simple program that uses if statements to check the amount spent and print the correct message.
📋 What You'll Learn
Create a variable called amount_spent with the exact value 75
Create a variable called discount_threshold with the exact value 50
Use an if statement to check if amount_spent is greater than or equal to discount_threshold
Print "You get a discount!" if the condition is true
Print "No discount this time." if the condition is false
💡 Why This Matters
🌍 Real World
Stores and online shops often give discounts based on how much a customer spends. This helps encourage more buying.
💼 Career
Understanding if statements is key for any programming job because decisions in code depend on conditions.
Progress0 / 4 steps
1
Create the amount spent variable
Create a variable called amount_spent and set it to the number 75.
Python
Need a hint?

Use the equals sign = to assign the value 75 to amount_spent.

2
Set the discount threshold
Create a variable called discount_threshold and set it to the number 50.
Python
Need a hint?

Remember to use the equals sign = to assign the value 50 to discount_threshold.

3
Write the if statement to check the amount
Write an if statement that checks if amount_spent is greater than or equal to discount_threshold. Inside the if block, write a print statement to display "You get a discount!". Add an else block with a print statement to display "No discount this time.".
Python
Need a hint?

Use if and else keywords. Indent the print statements inside the blocks.

4
Display the result
Run the program and print the message that shows whether the customer gets a discount or not.
Python
Need a hint?

The program should print the message automatically when run.