Control Flow Challenges and Projects
Control Flow Challenges and Projects
Great job finishing this module.
You have learned how to use:
ifif elseelif- comparison operators
- logical operators
- nested conditions
match case- validation
Now it is time to practice everything together.
Quick Challenges
Try to solve these on your own.
Challenge 1: Age Checker
Build a program that checks age.
Steps:
- Ask the user to enter their age
- If age is 18 or more, print:
Adult - Otherwise, print:
Minor
Challenge 2: Even or Odd
Build a number checker.
Steps:
- Ask the user to enter a number
- If the number divided by 2 gives remainder
0, print:
Even - Otherwise, print:
Odd
Challenge 3: Password Checker
Build a password checker.
Steps:
- Store the correct password as
python123 - Ask the user to enter a password
- If the entered password matches the correct password, print:
Access granted - Otherwise, print:
Wrong password
Challenge 4: Grade Checker
Build a grading program.
Steps:
- Ask the user to enter marks
- If marks are 80 or more, print:
Grade A - If marks are 60 or more, print:
Grade B - Otherwise, print:
Grade C
Mini Projects
These projects combine many skills.
Project 1: Login System
Build a simple login checker.
Steps:
- Store the correct username as
admin - Store the correct password as
python123 - Ask the user to enter a username
- Ask the user to enter a password
Rules:
- If both username and password are correct, print:
Login successful - Otherwise, print:
Invalid login
Project 2: Ticket Checker
Build a cinema entry checker.
Steps:
- Ask the user to enter age
- Ask the user if they have a ticket (
yesorno)
Rules:
- If age is 18 or more and ticket is
yes, print:
Welcome - If age is 18 or more and ticket is
no, print:
Buy a ticket - Otherwise, print:
Too young
Project 3: Menu App
Build a menu program.
Steps:
-
Ask the user to enter a choice
-
Show these options:
1= Home2= Profile3= Settings
Rules:
- Use
match case - If user enters
1, print:
Home Page - If user enters
2, print:
Profile Page - If user enters
3, print:
Settings Page - Otherwise, print:
Invalid option
Final Challenge
Build a student result system.
Steps:
- Ask the user to enter name
- Ask the user to enter score
Rules:
- If score is 80 or more, result is:
Excellent - If score is 50 or more, result is:
Pass - Otherwise, result is:
Fail
Then print:
Name: Result
Example:
Sarah: Excellent
Real World Use Case
Every real app uses logic and validation. Login systems, school systems, stores, games, and websites all depend on decision-making.
Quiz
- Which statement checks many conditions?
- What does
andmean? - What is validation?
- When should you use
match case?
Assignment
Choose one mini project and improve it by adding more rules or better messages.
Summary
You completed the Control Flow module and practiced real challenges using Python logic and decision-making.