Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Python conditional expressions code

Practice choosing values with conditional expressions, composing them with larger expressions, and recognizing when the syntax should stay simple.

Beginner ~8 min read

Challenge 1

Choose the correct label based on whether age is at least 18.

python Your answer
age = 22
label = 
print(label)

Press Ctrl⌘Enter to check your answer

Challenge 2

Choose free shipping for orders of at least 30; otherwise charge 5.

python Your answer
subtotal = 24
shipping = 
print(shipping)

Press Ctrl⌘Enter to check your answer

Challenge 3

Create a message based on whether count is zero.

python Your answer
count = 0
message = 
print(message)

Press Ctrl⌘Enter to check your answer

Challenge 4

Add a 10 percent discount only when score is at least 90.

python Your answer
price = 100
score = 95
total = 
print(total)

Press Ctrl⌘Enter to check your answer