CONTENT
- Introduction
- Solved Problems
- Unsolved Problems
- Check Your Understanding
​Introduction
Solved Problems
​1. Even or Odd:
Determine whether a given number is even or odd
Output:
7 is an odd number
Explanation:
​2. Pass or Fail:
Determine if a student has passed or failed an exam, given their grade (A, B, C, D, E, or F). Student passes with grades A, B, or C.
Output:
Congratulations! You passed the exam.
Explanation:
​3. Voting Eligibility:
Check if a person is eligible to vote, given their age (the voting age is 18).
Output:
You are not eligible to vote.
Explanation:
​4. First Letter:
Check if a given word starts with the letter "A".
Output:
The word starts with the letter A.
Explanation:
​5. Sign of a Number:
Determine if a given number is positive or not (i.e., it's either zero or negative).
Output:
The number is negative.
Explanation:
Unsolved Problem
1. Library Book Reminder
Imagine you have a variable days_late that shows how many days a library book is overdue. Write a Python program using an if-else statement to check if this number is greater than 0. If it is, print a reminder to return the book. If it’s not, print a message saying the book is still on time.
2. School Bus Alert
Suppose you have a variable time_now set to the current hour (like 7 or 8). Create a Python program with an if-else statement to see if the time is 8 or later. If it is, print a warning that the school bus is leaving soon. If it’s earlier, print a message saying there’s still time.
3. Water Bottle Refill
You have a variable water_level showing the percentage of water left in your bottle. Write a Python program using an if-else statement to check if this level is less than 20. If it is, print a message to refill the bottle. If it’s not, print that the bottle is still full enough.
4. Room Light Control
Think of a variable is_dark set to True or False to show if a room is dark. Write a Python program with an if-else statement to check if it’s dark. If it is, print that the lights are turning on. If it’s not, print that the lights will stay off.
5. Shopping Budget Monitor
Create a Python program with a variable cart_total representing the total cost of items in a shopping cart in rupees. Using an if-else statement, determine if the total exceeds 3000. If it does, print a warning about going over budget; otherwise, print a confirmation that the purchase is within budget.
