Nested while loops
📖 Scenario: You are helping a small bakery organize their daily baking schedule. They bake different types of bread in batches. Each batch has a fixed number of loaves. You want to print out the baking plan showing each batch and the loaves inside it.
🎯 Goal: Build a program that uses nested while loops to print the batch number and loaf number for each loaf baked.
📋 What You'll Learn
Create a variable
batches with the value 3 representing the number of batches.Create a variable
loaves_per_batch with the value 4 representing loaves in each batch.Use a nested
while loop: the outer loop counts batches, the inner loop counts loaves.Print the batch number and loaf number in the format:
Batch 1, Loaf 1.💡 Why This Matters
🌍 Real World
Bakers and factory workers often need to organize tasks in batches and steps, so nested loops help automate schedules and reports.
💼 Career
Understanding nested loops is essential for programming tasks that involve multi-level data or repeated actions inside other repeated actions, common in software development and automation.
Progress0 / 4 steps