3717363-Python While Loops Basic
3717363-Python While Loops Basic
Each
question is designed to simulate real-world scenarios, making
the concepts relatable and engaging.
WHILE LOOP’s SCINARIO BASED QUESTIONS
Write a program to simulate an ATM that keeps asking the user for their PIN using a while loop.
The loop should terminate once the correct PIN is entered, or after 3 incorrect attempts.
Write a program that takes a password as input and uses a while loop to ensure it meets the
following criteria:
3. Recharge Reminder
A prepaid mobile plan expires after X days. Use a while loop to count down the days, displaying a
reminder each day, until the plan expires. When the count reaches 0, display "Plan Expired."
Write a program that continuously asks the user to input a valid email address using a while loop.
If the input is invalid, display an error message and prompt again.
Simulate loan repayment using a while loop. Start with a loan amount, subtract the monthly
payment each iteration, and display the remaining balance. Exit the loop when the loan is fully
repaid.
6. Quiz Game
Create a simple quiz game where the program keeps asking questions (e.g., "What is 5+3?") using
a while loop. Exit the loop if the user answers incorrectly or completes 5 questions correctly.
7. Temperature Check
A freezer stops working if the temperature exceeds a threshold (e.g., -5°C). Use a while loop to
simulate temperature readings every minute, and display a warning if the threshold is breached.
Simulate a parking lot with 10 available spaces. Use a while loop to keep accepting car entries and
decrement the space count. Stop the loop when no spaces are left.
Write a program for a toll booth that keeps track of the number of vehicles passing through and
stops collecting data when a user enters "stop." Display the total number of vehicles.
Simulate a shopping experience where the user has a limited budget. Keep allowing the user to
purchase items (by entering their price) using a while loop, and exit the loop when their budget is
exhausted.