
CH05 - If Statements (part 3)
Authored by Ramsey Seweingyawma
Computers
9th - 12th Grade
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
6 questions
Show all answers
1.
OPEN ENDED QUESTION
3 mins • 10 pts
Explain the difference between an if-elif-else chain and a series of independent if statements. When would you use one over the other? Provide an example for each.
Evaluate responses using AI:
OFF
2.
OPEN ENDED QUESTION
3 mins • 10 pts
The document states that when a list is used in an if statement, an empty list evaluates to False. Why is this a useful feature when dealing with user-provided input?
Evaluate responses using AI:
OFF
3.
OPEN ENDED QUESTION
3 mins • 10 pts
What is the purpose of checking if a list is not empty before running a for loop? What could happen if you don't perform this check?
Evaluate responses using AI:
OFF
4.
OPEN ENDED QUESTION
3 mins • 10 pts
Describe how you would use a loop and an if statement together to process each item in a list and handle one or more "special" items differently.
Evaluate responses using AI:
OFF
5.
OPEN ENDED QUESTION
3 mins • 10 pts
Pizza Topping Order: A pizzeria has a list of toppings they have in stock and a customer places an order with a list of requested toppings. Describe how you would write a program that loops through the customer's request and prints a message for each topping, indicating whether it has been added to the pizza or if it is unavailable.
Evaluate responses using AI:
OFF
6.
OPEN ENDED QUESTION
3 mins • 10 pts
Shopping Cart Validation: An e-commerce website has a list of items a user has placed in their shopping cart. Before processing the order, you need to verify that none of the items are from a list of banned_items. Describe how you would use an if statement with the not in keyword and a for loop to check each item in the shopping cart and print a message if a banned item is found.
Evaluate responses using AI:
OFF
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?