Open in TheBrain

While Loop: Usage and Examples

Here is the prompt to create the program

Prompt:

"Write a Python program that demonstrates the use of while loops and for loops for a small business simulation called 'Frank's Fruits.' The program should:

  1. Start by asking the user to stock the fruit stand with three types of fruits: Apples, Bananas, and Oranges. The user should input how many of each fruit are available, ensuring only non-negative integers are accepted.
  2. Ask if the user wants to open the fruit stand for the day. If the user says "yes," allow them to begin selling fruits. If the user says "no," display a message to "Have a good evening!" and stop the program.
  3. During the sales process:
  1. If the inventory for all fruits reaches 0:
  1. Include robust input validation to ensure only valid responses are accepted (e.g., non-negative integers for stock and quantity).

The program should demonstrate clear, structured use of loops and conditionals for educational purposes."

Attachments