Conditionals Logic Worksheet
Computing Foundations Independent Lab Study
Introduction to Conditionals: How Programs Make Decisions
Page 1 of 5
Turn In by End of Class
Student Name:
Period:
Date:
Learning Goal: Identify what conditionals are, evaluate Boolean values (True/False), use comparison operators, and trace if, elif, and else decisions.
1
Vocabulary Reference Desk
Keep this handy as your reference tool
Conditional: A rule causing a program to act only when a condition is met.
Condition: A statement that can be evaluated as either true or false.
Boolean: A value that is strictly either True or False.
Comparison: A check between two values producing a Boolean result.
if: Checks if a condition is true; executes code if it is.
elif: Checks another condition if previous condition was false.
else: Catch-all branch that executes when none of the previous conditions were true.
| Op | Meaning | Example |
|---|
| == | Equal to | 5 == 5 → True |
| != | Not equal to | 4 != 9 → True |
| > | Greater than | 8 > 3 → True |
| < | Less than | 2 < 10 → True |
| >= | Greater than or equal to | 7 >= 7 → True |
| <= | Less than or equal to | 3 <= 6 → True |
⚠️ CRITICAL PYTHON RULE
In Python, a single = assigns a value.
A double == compares two values to check if they match.
2
Everyday Conditionals
Identify condition and action
Humans make conditional decisions constantly. In each statement below, write down the Condition (the check) and the Action (what happens if true).
Model "IF it is raining, THEN bring an umbrella."
Condition: it is raining | Action: bring an umbrella
1. If your phone battery is below 20%, charge it.
Condition:
Action:
2. If the traffic light is red, stop.
Condition:
Action:
3. If your grade is 70% or higher, you pass.
Condition:
Action:
4. If the oven timer goes off, remove the food.
Condition:
Action:
5. If your password is incorrect, try again.
Condition:
Action:
What do all of these statements have in common?
Introduction to Conditionals • Computing Foundations Turn to Page 2 →
Part I: Evaluating & Reading Conditions
Page 2 of 5
3
True or False? (Boolean Evaluation)
Circle True or False for each expression
How would Python evaluate each comparison? Determine whether each expression produces True or False.
10 > 5
True False
15 >= 15
True False
8 < 3
True False
"yes" == "yes"
True False
"cat" != "dog"
True False
72 >= 70
True False
4 <= 3
True False
"apple" == "orange"
True False
4
Choose the Correct Operator
Options: == , != , > , < , >= , <=
Fill in the blank box with the exact Python operator that matches the English description.
1. The score is greater than 90:
score
90
2. The guess is equal to "python":
guess
"python"
3. The temperature is less than 32:
temp
32
4. The balance is not equal to zero:
balance
0
5. The grade is greater than or equal to 70:
grade
70
6. The age is less than or equal to 12:
age
12
5
Read the Conditional (Code Tracing)
Trace program behavior
Study each Python snippet. Answer each question based on how Python evaluates and executes the code.
score = 82
if score >= 70:
print("You passed!")
1. What condition is being checked?
2. Is the condition True or False?
3. What will the program display?
age = 11
if age >= 13:
print("Teen account")
1. What condition is being checked?
2. Is the condition True or False?
3. What will display? (Write "Nothing" if no output)
Introduction to Conditionals • Computing Foundations Turn to Page 3 →
Part II: Multi-Branch Decision Making
Page 3 of 5
Section 5 Continued: More Practice
player_lives = 0
if player_lives == 0:
print("Game Over!")
1. Condition checked:
2. True or False?
3. Program displays:
weather = "sunny"
if weather != "rainy":
print("Go to the park!")
1. Condition checked:
2. True or False?
3. Program displays:
6
Branching Decisions: if / elif / else
Handling multiple outcomes
Key Concept: A program can sometimes have more than two possible outcomes. Python checks conditions in order from top to bottom. As soon as one condition evaluates to True, Python runs that indented block and skips the rest. If none are true, it executes the else block.
Example 1: Letter Grade Classifier
score = 85
if score >= 90:
print("Excellent")
elif score >= 70:
print("Passing")
else:
print("Keep working")
1. Which condition is checked first?
2. If the first condition is false, what happens next?
3. What will this program print when score = 85?
4. What would it print if score = 95?
5. What would it print if score = 60?
Example 2: Real-World Scenario (Temperature Outfit Advisor)
temp = 48
if temp >= 80:
print("Wear shorts")
elif temp >= 55:
print("Wear light jacket")
else:
print("Wear heavy coat")
1. For temp = 48, is the first condition (temp >= 80) True or False?
2. For temp = 48, is the elif condition (temp >= 55) True or False?
3. What advice will this program print for temp = 48?
4. Give an example temperature that would trigger "Wear shorts":
Introduction to Conditionals • Computing Foundations Turn to Page 4 →
Part III: Logic Translation & Project Connection
Page 4 of 5
7
Translate Plain English into Conditional Logic
No Python syntax required
Programmers plan rules in structured plain English before typing Python code. Complete each conditional plan below.
1. Game Score: A game gives the player a prize if their score is at least 100.
IF:
THEN:
2. Temperature: A thermostat turns on the AC if the room temperature is greater than 75 degrees.
IF:
THEN:
3. Survey Percentage: A report flags a topic as "Approved" if the YES percentage is 50% or higher.
IF:
THEN:
4. Grade Decision (Full Branch): If a student earns 70 or higher, they pass; otherwise, they retake the quiz.
IF:
THEN:
ELSE:
8
Survey Connection (Our Previous Project)
Applying logic to your code
Recent Class Project Scenario: You wrote a program calculating survey percentages.
Suppose the survey outputs:
YES 65%
NO 35%
1. Is yes_percent > 50 True or False for this survey?
2. What should a program display if more than half of the class answered YES?
3. What should it display if exactly 50% answered YES?
4. What should it display if fewer than 50% answered YES?
Write Three Plain-Language Rules to Automate Your Survey Summary:
IF
ELIF
ELSE
Introduction to Conditionals • Computing Foundations Turn to Page 5 →
Part IV: Looking Ahead & Final Check
Page 5 of 5
9
Rock, Paper, Scissors Preview
Upcoming Python project
On our block day class, you will code a Rock, Paper, Scissors game in Python! A program must compare two player choices and decide which result occurs.
Game Logic Breakdown:
1. Rock beats:
2. Paper beats:
3. Scissors beats:
4. What exact condition creates a tie in the game?
5. What decisions will a computer need to make in order to determine a winner?
Write one plain-language conditional rule for Rock, Paper, Scissors:
IF
THEN
10
Final Check (Self-Check Review)
Review before submitting
1. What is a conditional in programming?
2. What are the only two Boolean values?
3. Difference between = and ==?
4. When does code inside an if block run?
5. When does code inside an else block run?
6. Write an everyday IF/THEN rule you used today:
📋 Before turning this in to the substitute teacher:
Completed every section Checked my answers Wrote name on Page 1 Turn in before leaving
Teacher / Sub Use
Score: _____ / 100
Initials: ________
Introduction to Conditionals • Computing Foundations End of Worksheet • Submit to Substitute