Conditionals Python Homework - CTRL Zombies


Python Popcorn Hack

number1 = 10
number2 = 0   

if number2 != 0:        # fill in the condition
    result = number1 / number2   # fill in the operator
    print("The answer is", result)  # fill in what to print
else:
    print("Error: Cannot divide by zero")  # fill in the missing word

Error: Cannot divide by zero

Part A: Answer the Question!

What does an if statement do in programming?

If it is true, it runs the code. If it is false, it doesn't.

Part B: Python Practice

Write a Python program that checks if a number score = 85 is a passing grade (≥ 60). Print “Pass” if true, otherwise "Fail".

# <-- Example Code

x = 19

if x >= 18:
    print("You can vote")
else:
    print("You are too young to vote")
score = 85

if score >= 60:
    print("Pass")
else:
    print("Fail")

Pass