Search Header Logo
Exploring Selection Statements in Python

Exploring Selection Statements in Python

Assessment

Presentation

Computers

9th - 12th Grade

Easy

Created by

N Ellis

Used 22+ times

FREE Resource

10 Slides • 13 Questions

1

Exploring Selection Statements in Python

An exploration of selection statements in Python, including if statements. Learn how to make decisions in your code based on conditions and control the flow of your program.

2

What exactly does this program do?

media

3

Multiple Choice

Print statement

1

Outputs a message on the screen

2

Gets data from the user

3

A decision

4

A loop controlled by a decision

4

Multiple Choice

Input statement

1

Outputs a message on the screen

2

Gets data from the user

3

A decision

4

A loop controlled by a decision

5

Multiple Choice

Question image
What is the name of the programming language we are learning?
1
Scratch
2
Python
3
Pie thin
4
Scribble

6

Selection Statements in Python

  • Selection statements allow us to control the flow of our program based on certain conditions.

  • Python provides two types of selection statements: if and if-else.

  • With if statements, we can execute a block of code only if a certain condition is true.

  • If-else statements allow us to execute different blocks of code based on different conditions.

  • Selection statements are essential for making decisions and creating dynamic programs.

7

Multiple Choice

What are the two types of selection statements in Python?

1

if and if-else

2

for and while

3

try and except

4

def and return

8

Multiple Choice

What will the output be from the following code?
print("Hello world!")
1
SyntaxError
2
Hello world!
3
"Hello world!"
4
print(Hello world!)

9

if Statement in Python

Trivia: The if statement in Python is used to execute a block of code only if a certain condition is true. It is also used to handle multiple conditions using if, elif, and else. Additionally, it can be used to check for equality using == and inequality using !=. Conditions can also be combined using and and or.

  • It is a fundamental control structure in Python programming.
  • It allows for decision-making and branching in the code.
  • It helps in making the code more flexible and adaptable.

10

Using the else Statement

  • The else statement is used in conjunction with if statement to execute a block of code when the condition is False.
  • It provides an alternative path of execution when the condition is not met.
  • The else statement is optional and can be used only once in an if statement.

11

Multiple Choice

What is the purpose of the else statement in Python?

1

To execute a block of code when the condition is True

2

To provide an alternative path of execution when the condition is not met

3

To check multiple conditions at once

4

To terminate the program

12

Comparison Operators in Python

  • == - equal to
  • != - not equal to
  • < - less than
  • > - greater than
  • <= - less than or equal to
  • >= - greater than or equal to

13

Multiple Choice

What is the symbol for 'less than or equal to' in Python?

1

==

2

!=

3

<=

4

>

14

Multiple Choice

What does this symbol represent?


>

1

Less than

2

Greater than

3

Equal to

4

Less than or equal to

15

Indentation in Python

  • Python requires indentation as part of the syntax

  • Indentation signifies the start and end of a block of code

  • Correct indentation is crucial, or the program may either not run, or give an incorrect result

media

16

Multiple Choice

What is crucial for selection statements in Python?

1

Indentation

2

Semicolons

3

Brackets

4

Quotation marks

17

  • If gives you two options

  • ELIF stands for Else, If and gives you more options

  • You can use it as many times as you like

The ELIF statement

media

18

Write a simple program that might be used inside a police speed camera:

The requirements are:

  • It must accept the driver’s speed

  • IF the speed is over 70mph, a message “Issue Fine” should appear on the speed gun

  • Otherwise it should display
    No Action

Write a program

media

19

  • Add an ELIF statement to the Speeding program

  • Issue a warning between 70 and 75mph 

  • Only issue a fine for 75mph and over

Using the ELIF statement

media

20

Reorder

Question image

Reorder the following

age = int(input("please enter your age "))

if age >= 14

print("welcome to the Club")

else

print("Sorry, you're not old enough to join yet")

1
2
3
4
5

21

Multiple Choice

What is python?
1
a programming language 
2
DTP software 
3
Spreadsheet software
4
Computer 

22

Multiple Choice

Question image

What is the name of the variable in this program?

1

print

2

colour

3

input

4

" "

23

Multiple Choice

Which is NOT a data type in Python?

1

integer

2

boolean

3

anchor

4

float

Exploring Selection Statements in Python

An exploration of selection statements in Python, including if statements. Learn how to make decisions in your code based on conditions and control the flow of your program.

Show answer

Auto Play

Slide 1 / 23

SLIDE