

Control Flow Revision
Presentation
•
•
Practice Problem
•
Hard
Joseph Dewhurst
FREE Resource
26 Slides • 37 Questions
1
PYTHON BLITZ
Control flow structures

2
While loop
Until a condition in the while statement's header is True, the body of the loop will be executed.
The body of the loop is demarcated by indentation (4 white spaces).
Iteration is a single execution of the body of the loop.
How often does the condition in the header of the while loop gets checked?
The condition in the while loop header gets checked at the beginning of a new iteration only after all the operations in the body of a loop have been executed.
3
Header condition of the while loop
any expression which evaluates to True
x > 0
a != b and a != c
True
a == b
score < = 500
Can you think of a condition?
4
Else, break and continue
or how to terminate or jump out of the while loop
5
Else, break and continue
Optional else statement after the body of the loop gets executed if the header condition in the while loops evaluates to False
Break statement executed in the body of the while loop terminates the loop without executing the else clause
Continue statement executed in the body of the while loop skips the rest of the operations in the body of the while loop and goes back to testing the expression.
6
Multiple Choice
It not known initially how many times the while loop will be iterated.
True
False
7
Multiple Select
If number zero is entered, the following will happen:
"If" statement will be exited, and while loop will executed again.
"If" statement will be exited, and while loop will be exited and the last "else" skipped.
8
Multiple Choice
The number of .. through the while loop is equal to the number of ..
iterations .. guesses
iterations .. incorrect guesses
iterations .. correct guessed
9
Open Ended
If the number 21 is entered, the following will happen:
10
Multiple Choice
Sign "!=" means
logical "OR"
logical "AND"
logical "EQUAL"
logical "NOT EQUAL"
11
Multiple Choice
In a Python program , a control structure:
directs the order of execution of the statements in the program
dictates what happens before te program starts and after it terminates
defines program-specific data structures
manages the input and output of control characters
12
Multiple Choice
An empty/null statement in python is ____________
go
pass
over
;
13
Multiple Choice
The order of statement execution in the form of top to bottom , is known as ______ construct
selection
repetition
sequence
flow
14
Multiple Choice
The ___________ construct allows to choose statements to be executed , depending upon the result of a condition.
selection
repetition
sequence
flow
15
Multiple Select
Which of the following statements will make a selection construct ?
if
for
if-else
while
16
Multiple Choice
What is the output of the above program ?
Am I here?
Or here ?
Am I here ? Or here ?
Or here ? Or over here ?
17
Multiple Choice
If the user inputs : 2<Enter> , what does the following code snippet print ?
Yes
No
May be
Nothing printed
Error
18
Multiple Select
Function range(3) is equivalent to "
range(1,3)
range(0,3)
range(0,3,1)
range(1,3,0)
19
Multiple Select
In for a in _________ : , the blank can be filled with
an iterable sequence
a range() function
a single value
an expression
20
Multiple Choice
Consider the following loop given below :
for i in range(5):
print(i)
How many times will this loop run ?
5
0
infinite
Error
21
Multiple Choice
The program snippet above is syntactically correct
False
True
22
Multiple Choice
You should be at least 18 years to vote. What should be the expression in the if statement that will print
can vote.
age >= 18
age = 18
age == 18
23
Multiple Choice
What is the output of the program above.
can vote
can drink
can vote can drink
24
Multiple Choice
What is the output of the above program
can vote
can drink
can vote
can drink
none of the above
25
Multiple Choice
What is the output of the code above
go watch cartoons
can vote
go get a girlfriend/boyfriend
26
Multiple Choice
For which value of age, will the output "go drink" get printed
It will never print
17
22
27
Multiple Choice
The program above will print
Nothing
tends to drink
tends to chitchat
28
Multiple Choice
The code above will print
python
java
None
29
Python flow control
​
30
31
32
33
Multiple Choice
What is the output of print(10 - 4 * 2)
2
12
10
0
34
Multiple Choice
Which of these following is not an operator group?
Logical
Comparison
Bitwise
Membership
Output
35
Multiple Choice
What is the output of the following code
x = 6
y = 2
print(x ** y)
print(x // y)
66
0
36
0
66
3
36
3
36
Multiple Choice
Which python operator means 'less than or equal to'?
>=
>
<
<=
37
Multiple Choice
x = 5
print(x > 3 and x < 10)
True
False
38
Multiple Choice
x = 5
y = 3
print(x == y)
True
False
39
Multiple Choice
x = 5
x%=3
print(x)
2
2.0
3
3.0
40
41
42
43
44
45
46
47
48
Fill in the Blanks
Type answer...
49
Fill in the Blanks
Type answer...
50
Fill in the Blanks
Type answer...
51
Fill in the Blanks
Type answer...
52
Fill in the Blanks
Type answer...
53
Mastering Control Flow Statements
Learn how to effectively use control flow statements in Python to control the flow of your program and make it more efficient. Explore concepts like if-else statements, loops, and conditional expressions to gain mastery over control flow in Python.
54
Programming control structures are constructs in computer programming that enable developers to control the flow of a program's execution. These structures determine the order in which statements or blocks of code are executed. They are essential for making decisions, repeating tasks, and creating logical sequences within a program. There are three primary types of control structures in programming: Sequential, Selection, and Repetetion.
Control Structures
55
Sequential Structure: In a sequential structure, code is executed one statement after another in a linear fashion. This is the default behavior of most programming languages. For example, if you have a series of statements, they will be executed in the order they appear in the code.
Control Structures: Sequential
56
Selection (Conditional) Structure: Selection structures allow the program to make decisions based on certain conditions. These conditions are typically expressed using conditional statements such as if, else if (or elif), and else. The program executes different code blocks based on whether specific conditions are met.
Control Structures: Selection
57
Repetition (Looping) Structure: Repetition structures enable the program to repeat a specific block of code multiple times. There are mainly two types of loops: for loops and while loops. They are used to iterate over collections, perform tasks a fixed number of times, or execute code until a specific condition is met.
Control Structures: Repetition
58
Control Flow Statements
59
Multiple Choice
Which control flow statements are used in Python?
if, else if, else
for, while
break, continue
if, else if, else, for, while, break, continue
60
Python Control Flow Statements
Trivia: Python offers a variety of control flow statements to control the execution of code. These include if, else if, else, for, while, break, and continue. These statements allow programmers to make decisions, loop through code, and control the flow of their programs.
61
Mastering Control Flow Statements in Python
for item in iterable: Loop through each item in an iterable object.
While Loop: Repeat a block of code as long as a condition remains true.
Loop Control Statements: Use 'break' to exit a loop prematurely, 'continue' to skip the current iteration, and 'else' to execute code when the loop completes without a 'break'.
62
Multiple Choice
Which control flow statement is used to repeat a block of code as long as a condition remains true?
for loop
while loop
loop control statements
enumerate
63
While Loop
Trivia: The while loop is used to repeat a block of code as long as a condition remains true. It is a fundamental control flow statement in programming. The condition is checked before each iteration, and if it evaluates to true, the code block is executed. If the condition becomes false, the loop is terminated. The while loop is commonly used for tasks such as iterating over arrays or performing repetitive calculations. It provides flexibility and allows for dynamic control of the loop.
PYTHON BLITZ
Control flow structures

Show answer
Auto Play
Slide 1 / 63
SLIDE
Similar Resources on Wayground
57 questions
Spelling, Capitalization & Punctuation
Presentation
•
9th - 12th Grade
58 questions
Chapter 29: Nervous and Endocrine system
Presentation
•
10th Grade
57 questions
Plant Cell Types
Presentation
•
11th Grade
57 questions
ESB Certification Domain 3: Production & Distribution
Presentation
•
6th - 12th Grade
57 questions
Les Adjectifs Possessifs
Presentation
•
9th - 12th Grade
58 questions
Invertebrates and Vertebrates
Presentation
•
9th Grade
56 questions
Characteristics of the Election Process
Presentation
•
7th Grade
55 questions
Science 9 - Unit A Review Slides
Presentation
•
9th Grade
Popular Resources on Wayground
20 questions
"What is the question asking??" Grades 3-5
Quiz
•
1st - 5th Grade
20 questions
“What is the question asking??” Grades 6-8
Quiz
•
6th - 8th Grade
10 questions
Fire Safety Quiz
Quiz
•
12th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
34 questions
STAAR Review 6th - 8th grade Reading Part 1
Quiz
•
6th - 8th Grade
20 questions
“What is the question asking??” English I-II
Quiz
•
9th - 12th Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
47 questions
8th Grade Reading STAAR Ultimate Review!
Quiz
•
8th Grade
Discover more resources for
20 questions
"What is the question asking??" Grades 3-5
Quiz
•
1st - 5th Grade
20 questions
“What is the question asking??” Grades 6-8
Quiz
•
6th - 8th Grade
10 questions
Fire Safety Quiz
Quiz
•
12th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
34 questions
STAAR Review 6th - 8th grade Reading Part 1
Quiz
•
6th - 8th Grade
20 questions
“What is the question asking??” English I-II
Quiz
•
9th - 12th Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
47 questions
8th Grade Reading STAAR Ultimate Review!
Quiz
•
8th Grade