Problem statements of while loop
Problem statements of while loop
"NumberGuess" is a simple game where the player needs to guess a randomly generated number
within a given range. Write a Python program to create a Number Guessing Game.
Write a Python program that implements the Number Guessing Game and keeps prompting the
player until they guess the correct number.
**Example Output:**
```
Number Guessing Game
---------------------
The primary focus of this problem is to practice using a `while` loop to repeatedly prompt the user
until a certain condition is met.
Write a Python program that uses a `while` loop to create a countdown timer. The program should
prompt the user to enter a positive integer representing the countdown duration in seconds. It should
then display the countdown, updating the remaining time every second until the countdown reaches
0.
**Example Output:**
Countdown Timer
---------------
5 seconds remaining...
4 seconds remaining...
3 seconds remaining...
2 seconds remaining...
1 second remaining...
Time's up!
The primary focus of this problem is to practice using a `while` loop for creating countdowns and
updating values.
Write a Python program that uses a `while` loop to calculate the sum of numbers from 1 to a given
positive integer `n`. The program should prompt the user to enter a positive integer `n` and then
calculate and display the sum of numbers from 1 to `n`.
**Example Output:**
Enter a positive integer: 5
The primary focus of this problem is to practice using a `while` loop to calculate the sum of numbers.
Q. 4 Problem Statement:
"Write a Python program that simulates a simple ATM (Automated Teller Machine) interface. The
program should display a menu to the user with the following options:
Check Balance
Deposit Funds
Withdraw Funds
Exit
The user can choose any of these options by entering the corresponding number.
If the user selects 'Check Balance,' the program should display the current account balance.
If the user selects 'Deposit Funds,' they should be asked to enter the amount they want to
deposit, and the program should update the account balance.
If the user selects 'Withdraw Funds,' they should be asked to enter the amount they want to
withdraw, and the program should update the account balance if there are sufficient funds.
If the user selects 'Exit,' the program should exit.
The program should continue to display the menu and accept user input until the user chooses
to exit."
This problem statement involves creating a menu-driven program with a while loop to simulate basic
ATM functionality.
Q 5. **Problem Statement:**
"Write a Python program that simulates a simple calculator. The program should display a menu to
the user with the following options:
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Exit
The user can choose any of these options by entering the corresponding number.
- If the user selects 'Addition,' the program should prompt them to enter two numbers and display the
result of adding them.
- If the user selects 'Subtraction,' they should be prompted to enter two numbers and the program
should display the result of subtracting the second number from the first.
- If the user selects 'Multiplication,' they should be prompted to enter two numbers and the program
should display the result of multiplying them.
- If the user selects 'Division,' they should be prompted to enter two numbers, and the program
should display the result of dividing the first number by the second (handle division by zero).
- If the user selects 'Exit,' the program should exit.
The program should continue to display the menu and accept user input until the user chooses to
exit."
This problem statement involves creating a menu-driven calculator program with a while loop to
perform arithmetic operations based on user input.
Q6. "Write a Python program that simulates a basic to-do list manager. The program should display
a menu to the user with the following options:
Add Task
View Tasks
Mark Task as Complete
Clear Completed Tasks
Exit
The user can choose any of these options by entering the corresponding number.
If the user selects 'Add Task,' the program should prompt them to enter a task description, and
the task should be added to the to-do list.
If the user selects 'View Tasks,' the program should display all the tasks in the to-do list, including
their status (completed or not).
If the user selects 'Mark Task as Complete,' they should be prompted to enter the task number
they want to mark as complete, and the program should update the task status accordingly.
If the user selects 'Clear Completed Tasks,' the program should remove all completed tasks from
the to-do list.
If the user selects 'Exit,' the program should exit.
The program should continue to display the menu and accept user input until the user chooses
to exit."
This problem statement involves creating a to-do list manager program with a while loop to manage
tasks based on user input.
Q 7. Write a Python program that simulates a basic inventory management system for a store. The
program should start with an initial inventory of products, each represented as a dictionary with
the following information: 'product_id', 'product_name', 'unit_price', and 'quantity_in_stock'. The
program should then display a menu to the user with the following options:
View Inventory
Add a New Product
Update Product Quantity
Calculate Total Inventory Value
Exit
The user can choose any of these options by entering the corresponding number.
If the user selects 'View Inventory,' the program should display a formatted list of all products
and their details.
If the user selects 'Add a New Product,' they should be prompted to enter the details of the new
product, and it should be added to the inventory.
If the user selects 'Update Product Quantity,' they should be asked to enter a product ID and the
new quantity, and the program should update the quantity in stock for that product.
If the user selects 'Calculate Total Inventory Value,' the program should calculate and display the
total value of all products in the inventory (quantity * unit price).
If the user selects 'Exit,' the program should exit.
The program should continue to display the menu and accept user input until the user chooses
to exit."
This problem statement involves creating a menu-driven program with a while loop to manage an
inventory of products and perform various operations on it based on user input.
"Write a Python program to create a simple password management system. The program should
implement the following logic:
Write a Python program that implements the password management system, allowing users a limited
number of attempts to enter the correct password.
**Example Output:**
**Example Output:**
"Write a Python program to create a simple quiz game. The program should implement the
following logic:
Write a Python program that implements the quiz game, allowing the player to answer questions until
they decide to quit or until a set number of questions have been asked.
**Example Output:**
Quiz Game
---------
Correct!
Correct!
Correct!
This problem statement focuses on using a `while` loop to manage the quiz game and track the
player's score.
Q 10.**Problem Statement:**
"Write a Python program to create a simple text-based chatbot. The program should implement the
following logic:
Write a Python program that implements the chatbot, allowing the user to have a conversation with it
and exit when they choose.
**Example Output:**
Chatbot: Hello! I'm your friendly chatbot. What's your name?
User: John
Chatbot: Nice to meet you, John. How can I assist you today?
User: What's the weather like today?
Chatbot: Today's weather is sunny with a high of 75°F.
User: Tell me a joke.
Chatbot: Sure, here's a joke: Why don't scientists trust atoms? Because they make up everything!
User: Goodbye
Chatbot: Goodbye, John! Have a great day!
This problem statement focuses on implementing a conversational chatbot using a `while` loop to
maintain the conversation until the user decides to exit.