Imagine you have a list of numbers from 1 to 10. You want to select only the numbers that are greater than 5. Which description best explains this filtering process?
Think about the condition that decides which numbers to keep.
Filtering means choosing items that meet a condition. Here, the condition is 'greater than 5', so only numbers above 5 are selected.
Which of the following is an example of a conditional statement used for filtering data?
Look for a statement that decides based on a condition.
A conditional statement checks if something is true before taking action. Here, it checks if the item is red to include it.
You have a list of fruits with their colors: apple (red), banana (yellow), grape (purple), lemon (yellow). You want to filter fruits that are yellow and start with the letter 'b'. Which fruits will you get?
Check both color and first letter conditions carefully.
The fruit must be yellow and start with 'b'. Banana is yellow and starts with 'b'. Lemon is yellow but starts with 'l'.
Consider a list of numbers: [2, 4, 6, 8, 10]. You apply a filter to select numbers that are even and less than 7. What is the resulting list?
Check which numbers are even and also less than 7.
All numbers are even, but only 2, 4, and 6 are less than 7, so they remain after filtering.
A store offers a discount only if a customer buys more than 3 items and the total price exceeds $50. If a customer buys 4 items costing $12 each, will they get the discount?
Calculate total price and check both conditions carefully.
The customer bought 4 items (more than 3), but total price is 4 × $12 = $48, which is less than $50, so no discount.