0
0
Pythonprogramming~15 mins

Logical operators in conditions in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Using Logical Operators in Conditions
📖 Scenario: You are creating a simple program to check if a person is eligible for a special discount based on their age and membership status.
🎯 Goal: Build a program that uses logical operators and and or in conditions to decide if a person gets a discount.
📋 What You'll Learn
Create a dictionary with exact keys and values for a person's details
Create a variable to hold the minimum age for discount
Use a condition with and and or to check eligibility
Print the exact output message based on eligibility
💡 Why This Matters
🌍 Real World
Logical operators help computers make decisions based on multiple rules, like checking if someone qualifies for a discount or access.
💼 Career
Understanding logical conditions is essential for programming tasks in software development, data validation, and automation.
Progress0 / 4 steps
1
Create the person's data
Create a dictionary called person with these exact entries: 'name': 'Emma', 'age': 22, and 'member': True.
Python
Need a hint?

Use curly braces {} to create the dictionary and separate each key-value pair with commas.

2
Set the minimum age for discount
Create a variable called min_age and set it to 18.
Python
Need a hint?

Just write min_age = 18 on a new line.

3
Check discount eligibility using logical operators
Create a variable called eligible that is True if the person's age is greater than or equal to min_age and the person is a member, or if the person's name is exactly 'Emma'. Use the logical operators and and or in the condition.
Python
Need a hint?

Use parentheses to group conditions and combine them with and and or.

4
Print the eligibility result
Write a print statement that outputs exactly: "Emma is eligible for discount: True" using the person['name'] and eligible variables with an f-string.
Python
Need a hint?

Use print(f"{person['name']} is eligible for discount: {eligible}") to show the result.