
10 Questions to Master Python Lists
-
Alphabetizing Data: How do you take a messy grocery list and sort it alphabetically using the .sort() method?
-
groceries = ["Milk", "Apples", "Bread", "Chicken", "Bananas", "Eggs", "Cheese", "Pasta", "Tomato Sauce", "Rice", "Cereal", "Yogurt", "Butter", "Onions", "Potatoes", "Garlic", "Carrots", "Spinach", "Coffee", "Tea", "Sugar", "Flour", "Salt", "Pepper", "Olive Oil", "Vinegar", "Beef", "Fish", "Oranges", "Apples"]
-
-
Statistical Analysis: How can you use a list of student grades to automatically find the average score, the highest grade, and the lowest grade?
-
grades = [88, 72, 95, 60, 45, 99, 82, 77, 91, 68, 55, 84, 89, 73, 92, 41, 100, 79, 85, 63, 71, 88, 94, 67, 80, 76, 59, 83, 90, 74]
-
-
Dynamic Updates: How do you build a to-do tracker that allows a user to append() new tasks and remove() completed ones by name?
-
tasks = ["Wash car", "Pay rent", "Buy milk", "Walk dog", "Clean kitchen", "Reply to emails", "Study Python", "Call mom", "Gym workout", "Laundry", "Water plants", "Fix sink", "Read book", "Write blog", "Prepare lunch", "Mow lawn", "Paint fence", "Update CV", "Organize desk", "Grocery shop", "Schedule dentist", "Vaccuum", "Iron shirts", "Refill prescription", "Dust shelves"]
-
-
Ranking Systems: How do you sort a gaming leaderboard so that the largest numbers appear first using reverse=True?
-
leaderboard = [1200, 450, 2300, 890, 1500, 2100, 300, 1750, 990, 1340, 2500, 1100, 670, 1820, 2050, 400, 1600, 1250, 900, 2200, 1400, 310, 1980, 560, 2450]
-
-
Data Filtering: How do you use List Comprehension to create a new list containing only products that cost less than $50?
-
prices = [12.99, 45.00, 120.50, 5.99, 89.99, 34.50, 15.00, 2.99, 150.00, 49.99, 60.00, 12.45, 8.90, 110.00, 25.00, 4.50, 99.00, 30.00, 55.00, 19.99, 44.95, 7.25, 13.00, 200.00, 39.99]
-
-
Cleaning Datasets: How can you quickly remove all duplicate entries from a list of email addresses by converting it to a set and back?
-
emails = ["test@me.com", "admin@site.com", "user@web.com", "test@me.com", "info@org.com", "user@web.com", "sales@corp.com", "admin@site.com", "hr@corp.com", "dev@web.com", "test@me.com", "support@site.com", "info@org.com", "user1@web.com", "user2@web.com", "hr@corp.com", "dev@web.com", "ceo@corp.com", "test@me.com", "admin@site.com", "staff@org.com", "web@site.com", "help@web.com", "sales@corp.com", "marketing@corp.com"]
-
-
Memory Management: How do you demonstrate the difference between a Shallow Copy and a Deep Copy when managing a nested inventory list?
-
inventory = [["iPhone", 10], ["MacBook", 5], ["iPad", 8], ["Watch", 15], ["AirPods", 20], ["iMac", 3], ["Cables", 50], ["Cases", 40], ["Chargers", 30], ["Mouse", 12], ["Keyboard", 10], ["Monitor", 6], ["Adapter", 25], ["Battery", 18], ["Screen Protector", 60], ["Stand", 4], ["Microphone", 7], ["Speaker", 9], ["Webcam", 11], ["Hub", 14]]
-
-
Membership Testing: How do you use the in keyword to check if a specific person’s name is already on a VIP guest list?
-
vip_guests = ["Alice", "Bob", "Charlie", "Diana", "Edward", "Fiona", "George", "Hannah", "Ian", "Julia", "Kevin", "Laura", "Mike", "Nina", "Oscar", "Paula", "Quinn", "Rose", "Steve", "Tina", "Ursula", "Victor", "Wendy", "Xavier", "Yara", "Zack", "Arthur", "Beatrice", "Caleb", "Daisy"]
-
-
Inventory Totals: How do you calculate the total cost of a shopping cart and count how many items are currently in it using sum() and len()?
-
cart_values = [5.50, 10.00, 2.99, 15.75, 1.25, 20.00, 4.50, 8.90, 12.00, 0.99, 6.45, 3.20, 18.00, 7.50, 11.25, 2.50, 5.00, 9.99, 14.50, 22.00, 1.50, 4.25, 3.75, 13.00, 6.00]
-
-
Time-Series Slicing: How do you use List Slicing ([start:stop]) to extract only the weekend temperatures from a list containing a full week of data?
-
# Represents 28 days (4 weeks) of temperatures
-
temps = [22, 24, 21, 25, 28, 30, 29, 23, 22, 25, 26, 27, 31, 32, 24, 25, 24, 22, 26, 28, 27, 21, 20, 23, 25, 29, 30, 28]
-
