Written by PIRATE KING
Now, let's test your knowledge with a quiz. In addition to the short reviews at the end of each section, I've compiled 10 comprehensive questions covering all our previous topics. Moving forward, you can expect a larger cumulative quiz like this every few chapters to help lock in your learning. This quiz features a mix of multiple-choice, multiple-selection, true or false, and practical coding exercises. All questions include instant answer keys—even the coding challenges—so you can track your progress in real-time.
1. Which of the following lines is a valid Python comment?
2. Which of the following is NOT a recommended Python coding convention according to Pep 8? Choose all that apply.
3. Python Boolean values must start with lowercase letters (e.g. true, false).
4. Which of the following statements about None in Python is correct?
5. Which escape sequence inserts a tab in a Python string?
6. Which of the following expressions evaluate to True, assuming s = "python programming"?
7. Secret Code Extractor
You are given a secret message: message = "X9-ALABASTA-7Q". Write Python code to:
"ALABASTA""ALABASTA" (e.g. "X9-")."ALABASTA" (e.g. -7Q).Expected output:
X Q ALABASTA X9- -7Q
8. Snack Bill Calculator
Write a Python program that:
price_chips = 2.75, price_juice = 1.40total.0.50 to total in one step (e.g. +=).total to 2 decimal places.Final total: $11.559. Movie Ticket Price Calculator
Write a program that calculates the ticket price based on the customer's age.
age (you can set it directly in code to any number).if, elif, and else statements to decide the ticket price based on this:Your ticket price is $XX. where XX is the price based on age. For example,age = 20, output: Your ticket price is $12age = 70, output: Your ticket price is $810. Online Store Discount Checker
Write a Python program that determines whether a customer qualifies for an online store discount and calculates the final price.
customer_name (string), e.g. "Alice"purchase_amount (float), e.g. 120.50is_member (boolean), e.g. True or Falsecustomer_name in uppercase as Customer code: XYZ.Customer code: ALI Original purchase: $120.51 Member discount applied: True Final price: $102.43