If Statements in Python: Making Decisions with Code
If Statements in Python: Making Decisions with Code
1 / 13
suivant
Slide 1: Diapositive
Cette leçon contient 13 diapositives, avec quiz interactifs et diapositives de texte.
Éléments de cette leçon
If Statements in Python: Making Decisions with Code
Slide 1 - Diapositive
Cet élément n'a pas d'instructions
Learning Objective
At the end of the lesson, you will be able to write and use if statements in Python to make decisions in your code.
Slide 2 - Diapositive
Introduce the learning objective and explain why it's important for students to learn if statements.
What do you already know about decision-making using code?
Slide 3 - Carte mentale
Cet élément n'a pas d'instructions
What are If Statements?
If statements are used to make decisions in code. They allow your program to take different actions based on whether a condition is true or false.
Slide 4 - Diapositive
Explain the concept of if statements and provide a simple example.
Syntax of If Statements
The syntax of an if statement in Python is: if condition: code to execute if condition is true
Slide 5 - Diapositive
Explain the syntax of if statements and provide an example.
Using Comparison Operators
To create conditions in if statements, you can use comparison operators such as == (equal), != (not equal), > (greater than), < (less than), >= (greater than or equal to), and
Slide 6 - Diapositive
Explain the different comparison operators and provide examples.
Else Statements
Else statements allow you to provide an alternative action to take if the condition in the if statement is false. The syntax is: if condition: code to execute if condition is true else: code to execute if condition is false
Slide 7 - Diapositive
Explain the concept of else statements and provide an example.
Elif Statements
Elif statements allow you to specify additional conditions to check if the first condition is false. The syntax is: if condition: code to execute if condition is true elif condition2: code to execute if condition2 is true else: code to execute if all conditions are false
Slide 8 - Diapositive
Explain the concept of elif statements and provide an example.
Nested If Statements
You can also nest if statements inside other if statements to create more complex conditions. The syntax is: if condition1: if condition2: code to execute if both conditions are true
Slide 9 - Diapositive
Explain the concept of nested if statements and provide an example.
Practice Problems
Practice using if statements by completing the following problems:
Slide 10 - Diapositive
Provide practice problems for students to complete and encourage them to ask questions if they need help.
Write down 3 things you learned in this lesson.
Slide 11 - Question ouverte
Have students enter three things they learned in this lesson. With this they can indicate their own learning efficiency of this lesson.
Write down 2 things you want to know more about.
Slide 12 - Question ouverte
Here, students enter two things they would like to know more about. This not only increases involvement, but also gives them more ownership.
Ask 1 question about something you haven't quite understood yet.
Slide 13 - Question ouverte
The students indicate here (in question form) with which part of the material they still have difficulty. For the teacher, this not only provides insight into the extent to which the students understand/master the material, but also a good starting point for the next lesson.