Download presentation
Presentation is loading. Please wait.
1
How did you decide what to wear today?
2
You made a decision Based on some ‘condition’
What was one of the conditions you used today To decide what to wear? To decide what to have for breakfast / lunch?
3
Conditional Statements
If…. Then,.... Else…. Conditional Statements
4
Which box should I open? Blue Black
5
Open box with most votes
if numofBlue > numofBlack open Blue box else: open Black box
6
Comparison Operators Read this more as “… is set equal to”. This is different from when we set a variable equal to some value (example: name=input() or candy_pieces = 12) == equal to != not equal to < less than > greater than <= less than or equal to >= greater than or equal to
7
What would happen if… The following program was entered… x = 15 if x == 25: print (“pizza is yummy”) else: print (“I am one cool high schooler”)
8
What would happen if… The following program was entered… x = 35 y = 52 if x != 25 and y == 52: print( “Pizza is yummy”) else: print(“ I am an awesome student”)
9
Let’s try this together
print (“please enter your password“) n = input( ) if n==“Password123”: print (“Welcome, correct user”) else: print (“Incorrect, try again”)
10
Create a program: Write a program using an IF statement, which will do the following: If the variable “hair” is equal to “looking good”, then display “put it on the gram!” else, display “maybe you should wear a hat today.” Test your program with a variety of foods variable = input( )
11
What else? How else might you use a conditional (if) statement?
What to wear – weather What show to watch tonight Which assignment to work on first (this could get complex! ) More conversation How might this work in a game?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.