Array Traversal Patterns
📖 Scenario: You are working on a simple inventory system for a small bookstore. The store keeps a list of book titles and their prices. You want to practice going through this list to find books that meet certain price conditions.
🎯 Goal: Build a program that creates a list of book prices, sets a price limit, finds all books cheaper than or equal to that limit, and prints those prices.
📋 What You'll Learn
Create a list called
book_prices with the exact values: 12.99, 7.50, 15.20, 5.99, 9.99Create a variable called
price_limit and set it to 10.00Use a
for loop with the variable price to traverse book_prices and collect prices less than or equal to price_limit into a list called affordable_booksPrint the
affordable_books list💡 Why This Matters
🌍 Real World
Filtering items based on conditions is common in shopping apps, inventory systems, and data analysis.
💼 Career
Understanding how to traverse arrays and apply conditions is a fundamental skill for software developers and data analysts.
Progress0 / 4 steps