SlideShare a Scribd company logo
Computational Thinking with
Programming
Fall 2019
@csebennett
@cse_bennett
Control
Structures
Control
Structures
• Control flow is the order that instructions are executed in a program.
• A control statement is a statement that determines the control flow of
a set of instructions.
• Types of Control:
• Sequential control: Instructions are executed in the order that
they are written
• Selection control: Selectively executes the instructions.
E.g. Decision Control
• Iterative control: Repeatedly executes the instructions. E.g. Loops.
Selection Control or Decisions
(It is a control statement providing selective execution of instructions)
• if statements
• if else statements
• elif statements
• nested if conditions
Decisions
in a
Python
program
If Statement
It is a selection control statement based on the
value of a given Boolean expression
if statement in python takes an expression with it.
If the expression results to True
• then the block of statements under it is executed.
If it results to False
• then the block is skipped and control transfers to the statements
after the block.
Remember to indent the statements in a block equally
Expression’s value can be True or False.
We may want to do something only when a certain condition is true.
Syntax:
if test expression:
statement(s)
If Statement: Example
Example: What will be the output ?
1.
2.
3.
4.
5.
Example: What will be the output ?
1.
2.
3.
4.
5.
Output: Smaller
Output: Finish
Output: yay
Output: 3 is a positive number.
This is always printed.
Output: This is also always printed.
if...else Statement
a.k.a. Two way decisions
What happens when the
condition is untrue or false?
We can mention that it in the
block after the else statement.
An ‘else’ statement comes
right after the block after ‘if’.
Example
Syntax:
if test expression:
Body of if
else:
Body of else
Header, Suite
and Indentation
• One unique aspect of Python is that the amount of
indentation of each program line is significant.
Nested if statements (multi-way selection)
You can put an if
statement in the
block under another
if statement.
This is to implement
further checks.
Nested if statements: Example
Example: What will be the output?
Example: What will be the output?
if...elif...else Statement
Replacement to
the else-if
statements
More than one
condition to
check
If condition 1 isn’t
True, condition 2
is checked.
If it isn’t true,
condition 3 is
checked.
if...elif...else Statement: Example Use
Syntax:
if test expression:
Body of if
elif test expression:
Body of elif
else:
Body of else
Example:
What will be
the output?
Example:
What will be
the output?
Single Statement Condition
Write a single statement under if
Exercise
Find out the Max of three numbers
Maximum between 3 numbers
Maximum between 3 numbers
Maximum between 3 numbers
MCQs
1. All if statements must contain either an
else or elif header.
a) TRUE
b) FALSE
2. Which of the following statements are
true regarding headers in Python?
a) Headers begin with a keyword and
end with a colon.
b) Headers always occur in pairs.
c) All headers of the same compound
statement must be indented the
same amount.
3. Which of the following statements is true?
a) Statements within a suite can be indented a
different amount.
b) Statements within a suite can be indented a
different amount as long as all headers in
the statement that it occurs in are indented
the same amount.
c) All headers must be indented the same
amount as all other headers in the same
statement, and all statements in a given
suite must be indented the same amount.
4. The elif header allows for,
a) Multi-way selection that cannot be
accomplished otherwise
b) Multi-way selection as a single if statement
c) The use of a “catch-all” case in multi-way
selection
MCQs: Answers
1. All if statements must contain either an
else or elif header.
a) TRUE
b) FALSE
2. Which of the following statements are
true regarding headers in Python?
a) Headers begin with a keyword and
end with a colon.
b) Headers always occur in pairs.
c) All headers of the same compound
statement must be indented the
same amount.
3. Which of the following statements is true?
a) Statements within a suite can be indented a
different amount.
b) Statements within a suite can be indented a
different amount as long as all headers in
the statement that it occurs in are indented
the same amount.
c) All headers must be indented the same
amount as all other headers in the same
statement, and all statements in a given
suite must be indented the same amount.
4. The elif header allows for,
a) Multi-way selection that cannot be
accomplished otherwise
b) Multi-way selection as a single if statement
c) The use of a “catch-all” case in multi-way
selection
Iterative Control (Loop)
• An iterative control statement is a control
statement that allows for the repeated
execution of a set of statements.
• Due to their repeated execution, iterative
control structures are commonly referred to as
“loops.
• Loop Statements:
• While
• For
• Nested loop
While Statement (indefinite loop)
• A while statement is an iterative control statement that repeatedly executes a set of
statements based on a provided Boolean expression (condition).
Example 1
• Find all even numbers from 0 to n. where, n is given by user.
Example 2
• Print all even numbers between n to m. m should be greater than n.
Example 3
Write a program to take numbers from the user until he enter 0 as
input. then print sum of all entered number.
Example 4
• Write an efficient program to determine sum of N natural numbers
where N is given by user.
For Loop
(definite loop)
• A for loop is used for iterating over a
sequence (that is either a list, a tuple,
a dictionary, a set, or a string). Can
execute a set of statements, once for
each item in a list, tuple, set etc.
• Example:
Syntax:
for iterating_var in sequence:
statements(s)
Loop to read
sequence
Sequences
• Sequence of character - 'QWERTYUIOPASDFGHJKL’
• Sequence of words - ['abc','def','efg','ijk’]
• Sequence of numbers - [1,2,3,4,5,6,7,8,9]
• Sequence of mix data – [‘Suvi’, 4, “LKG”, “Bennett University”, 98.5
Sequence of numbers can also be generated as:
• range(start, end, difference)
• range(3) = (0,1,2)
• range(1,5) = (1,2,3,4)
• range(3,9,2) = (3, 5, 7)
• range(9,2,-1) = (9,8,7,6,5,4,3)
• range(9,2,1) = []
For Loop: What will be the output?
1.
2.
3.
4.
5.
For Loop: Answers to Previous Questions
1 2 3 4 5
•Let one grain of wheat be placed on the first square
of a chessboard, two grains on the second square,
four grains on the third square, eight grains on the
fourth square, and so on until all square are filled in
chessboard. what will be the total weight in ton of
grains on whole 8×8 chessboard? If 15432 grains in
one kg and 907.18 kg in one ton then.
Problem
Exercise 2
Week 4.pptx computational thinking and programming
Week 4.pptx computational thinking and programming
Week 4.pptx computational thinking and programming
Nested Loop
• Loop inside a loop a is called nested loop.
• Example:
Nested Loop: What will be the output?
1.
2.
3.
4.
5.
Find all prime numbers between given two numbers
Find first 100 prime numbers start from 2.
Find number is Strong or not
If the sum of the factorial of the digits in a number is equal to the original number, the
number is a strong number.
Accept the limit and print the strong numbers from 1 to
the given limit.
Week 4.pptx computational thinking and programming
Infinite loop
• An infinite loop is an iterative control structure
that never terminates (or eventually terminates
with a system error).
• Infinite loops are generally the result of
programming errors.
• For example: if the condition of a while loop can
never be false, an infinite loop will result when
executed.
Loop Control Statements
• Break Statement: Terminates the loop statement and transfers execution to the
statement immediately following the loop.
• Continue Statement: Causes the loop to skip the remainder of its body and
immediately retest its condition prior to reiterating.
• Pass Statement:The pass statement in Python is used when a statement is required
syntactically but you do not want any command or code to execute.
Use of pass in if:
a = 33
b = 200
if b > a:
pass
Example:
for letter in 'Python’:
if letter == 'h’:
pass
print('This is pass block’)
print('Current Letter :', letter)
print(“Loop Ended!“)
Output:
Current Letter : P
Current Letter : y
Current Letter : t
This is pass block
Current Letter : h
Current Letter : o
Current Letter : n
Loop Ended
Break and Continue: Examples
• Break Statement:
• Continue Statement:
Ex.1: fruits =
["apple", "banana", "cherry"]
for x in fruits:
print(x)
if x == "banana":
break
Output:
apple
banana
Ex.2: fruits =
["apple", "banana", "cherry"]
for x in fruits:
if x == "banana":
break
print(x)
fruits =
["apple", "banana", "cherry"]
for x in fruits:
if x == "banana":
continue
print(x)
Output:
apple
cherry
MCQs
1. A while loop continues to iterate until its
condition becomes false.
a) TRUE
b) FALSE
2. A while loop executes zero or more times.
a) TRUE
b) FALSE
3. All iteration can be achieved by a while loop.
a) TRUE
b) FALSE
4. An infinite loop is an iterative control
structures that,
a) Loops forever and must be forced to
terminate
b) Loops until the program terminates with a
system error
c) Both of the above
5. The terms definite loop and indefinite loop
are used to indicate whether,
a) A given loop executes at least once
b) The number of times that a loop is
executed can be determined before the
loop is executed.
c) Both of the above
6. A Boolean flag is,
a) A variable
b) Has the value True or False
c) Is used as a condition for control
statements
d) All of the above
MCQs: Answers
1. A while loop continues to iterate until its
condition becomes false.
a) TRUE
b) FALSE
2. A while loop executes zero or more times.
a) TRUE
b) FALSE
3. All iteration can be achieved by a while loop.
a) TRUE
b) FALSE
4. An infinite loop is an iterative control
structures that,
a) Loops forever and must be forced to
terminate
b) Loops until the program terminates with a
system error
c) Both of the above
5. The terms definite loop and indefinite loop
are used to indicate whether,
a) A given loop executes at least once
b) The number of times that a loop is
executed can be determined before
the loop is executed.
c) Both of the above
6. A Boolean flag is,
a) A variable
b) Has the value True or False
c) Is used as a condition for control
statements
d) All of the above

More Related Content

Similar to Week 4.pptx computational thinking and programming (20)

PPTX
1. control structures in the python.pptx
DURAIMURUGANM2
 
PDF
Python Decision Making And Loops.pdf
NehaSpillai1
 
PDF
E-Notes_3721_Content_Document_20250107032537PM.pdf
aayushihirpara297
 
PDF
Python Flow Control
Mohammed Sikander
 
PPTX
Conditional and control statement
narmadhakin
 
PDF
basic of desicion control statement in python
nitamhaske
 
PDF
Python unit 2 M.sc cs
KALAISELVI P
 
PPTX
Python programming workshop session 2
Abdul Haseeb
 
PDF
conditionalanddvfvdfvdvdcontrolstatement-171023101126.pdf
sdvdsvsdvsvds
 
PDF
2 Python Basics II meeting 2 tunghai university pdf
Anggi Andriyadi
 
PPTX
TN 12 computer Science - ppt CHAPTER-6.pptx
knmschool
 
PPTX
PROBLEM SOLVING AND PYTHON PROGRAMMING UNIT 2
MulliMary
 
PPTX
Python if_else_loop_Control_Flow_Statement
AbhishekGupta692777
 
PPTX
Chapter 9 Conditional and Iterative Statements.pptx
XhelalSpahiu
 
PPT
Control structures pyhton
Prakash Jayaraman
 
PDF
loops.pdf
AmayJaiswal4
 
DOCX
Python unit 3 and Unit 4
Anandh Arumugakan
 
PPTX
Introduction To Programming with Python Lecture 2
Syed Farjad Zia Zaidi
 
PPSX
class interview demo
HELP4STUDENTS
 
PPTX
Demo for Class.pptx
HELP4STUDENTS
 
1. control structures in the python.pptx
DURAIMURUGANM2
 
Python Decision Making And Loops.pdf
NehaSpillai1
 
E-Notes_3721_Content_Document_20250107032537PM.pdf
aayushihirpara297
 
Python Flow Control
Mohammed Sikander
 
Conditional and control statement
narmadhakin
 
basic of desicion control statement in python
nitamhaske
 
Python unit 2 M.sc cs
KALAISELVI P
 
Python programming workshop session 2
Abdul Haseeb
 
conditionalanddvfvdfvdvdcontrolstatement-171023101126.pdf
sdvdsvsdvsvds
 
2 Python Basics II meeting 2 tunghai university pdf
Anggi Andriyadi
 
TN 12 computer Science - ppt CHAPTER-6.pptx
knmschool
 
PROBLEM SOLVING AND PYTHON PROGRAMMING UNIT 2
MulliMary
 
Python if_else_loop_Control_Flow_Statement
AbhishekGupta692777
 
Chapter 9 Conditional and Iterative Statements.pptx
XhelalSpahiu
 
Control structures pyhton
Prakash Jayaraman
 
loops.pdf
AmayJaiswal4
 
Python unit 3 and Unit 4
Anandh Arumugakan
 
Introduction To Programming with Python Lecture 2
Syed Farjad Zia Zaidi
 
class interview demo
HELP4STUDENTS
 
Demo for Class.pptx
HELP4STUDENTS
 

Recently uploaded (20)

PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Ad

Week 4.pptx computational thinking and programming

  • 1. Computational Thinking with Programming Fall 2019 @csebennett @cse_bennett
  • 3. Control Structures • Control flow is the order that instructions are executed in a program. • A control statement is a statement that determines the control flow of a set of instructions. • Types of Control: • Sequential control: Instructions are executed in the order that they are written • Selection control: Selectively executes the instructions. E.g. Decision Control • Iterative control: Repeatedly executes the instructions. E.g. Loops.
  • 4. Selection Control or Decisions (It is a control statement providing selective execution of instructions) • if statements • if else statements • elif statements • nested if conditions Decisions in a Python program
  • 5. If Statement It is a selection control statement based on the value of a given Boolean expression if statement in python takes an expression with it. If the expression results to True • then the block of statements under it is executed. If it results to False • then the block is skipped and control transfers to the statements after the block. Remember to indent the statements in a block equally Expression’s value can be True or False. We may want to do something only when a certain condition is true. Syntax: if test expression: statement(s)
  • 7. Example: What will be the output ? 1. 2. 3. 4. 5.
  • 8. Example: What will be the output ? 1. 2. 3. 4. 5. Output: Smaller Output: Finish Output: yay Output: 3 is a positive number. This is always printed. Output: This is also always printed.
  • 9. if...else Statement a.k.a. Two way decisions What happens when the condition is untrue or false? We can mention that it in the block after the else statement. An ‘else’ statement comes right after the block after ‘if’.
  • 10. Example Syntax: if test expression: Body of if else: Body of else
  • 11. Header, Suite and Indentation • One unique aspect of Python is that the amount of indentation of each program line is significant.
  • 12. Nested if statements (multi-way selection) You can put an if statement in the block under another if statement. This is to implement further checks.
  • 14. Example: What will be the output?
  • 15. Example: What will be the output?
  • 16. if...elif...else Statement Replacement to the else-if statements More than one condition to check If condition 1 isn’t True, condition 2 is checked. If it isn’t true, condition 3 is checked.
  • 17. if...elif...else Statement: Example Use Syntax: if test expression: Body of if elif test expression: Body of elif else: Body of else
  • 20. Single Statement Condition Write a single statement under if
  • 21. Exercise Find out the Max of three numbers
  • 22. Maximum between 3 numbers
  • 23. Maximum between 3 numbers
  • 24. Maximum between 3 numbers
  • 25. MCQs 1. All if statements must contain either an else or elif header. a) TRUE b) FALSE 2. Which of the following statements are true regarding headers in Python? a) Headers begin with a keyword and end with a colon. b) Headers always occur in pairs. c) All headers of the same compound statement must be indented the same amount. 3. Which of the following statements is true? a) Statements within a suite can be indented a different amount. b) Statements within a suite can be indented a different amount as long as all headers in the statement that it occurs in are indented the same amount. c) All headers must be indented the same amount as all other headers in the same statement, and all statements in a given suite must be indented the same amount. 4. The elif header allows for, a) Multi-way selection that cannot be accomplished otherwise b) Multi-way selection as a single if statement c) The use of a “catch-all” case in multi-way selection
  • 26. MCQs: Answers 1. All if statements must contain either an else or elif header. a) TRUE b) FALSE 2. Which of the following statements are true regarding headers in Python? a) Headers begin with a keyword and end with a colon. b) Headers always occur in pairs. c) All headers of the same compound statement must be indented the same amount. 3. Which of the following statements is true? a) Statements within a suite can be indented a different amount. b) Statements within a suite can be indented a different amount as long as all headers in the statement that it occurs in are indented the same amount. c) All headers must be indented the same amount as all other headers in the same statement, and all statements in a given suite must be indented the same amount. 4. The elif header allows for, a) Multi-way selection that cannot be accomplished otherwise b) Multi-way selection as a single if statement c) The use of a “catch-all” case in multi-way selection
  • 27. Iterative Control (Loop) • An iterative control statement is a control statement that allows for the repeated execution of a set of statements. • Due to their repeated execution, iterative control structures are commonly referred to as “loops. • Loop Statements: • While • For • Nested loop
  • 28. While Statement (indefinite loop) • A while statement is an iterative control statement that repeatedly executes a set of statements based on a provided Boolean expression (condition).
  • 29. Example 1 • Find all even numbers from 0 to n. where, n is given by user.
  • 30. Example 2 • Print all even numbers between n to m. m should be greater than n.
  • 31. Example 3 Write a program to take numbers from the user until he enter 0 as input. then print sum of all entered number.
  • 32. Example 4 • Write an efficient program to determine sum of N natural numbers where N is given by user.
  • 33. For Loop (definite loop) • A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). Can execute a set of statements, once for each item in a list, tuple, set etc. • Example: Syntax: for iterating_var in sequence: statements(s) Loop to read sequence
  • 34. Sequences • Sequence of character - 'QWERTYUIOPASDFGHJKL’ • Sequence of words - ['abc','def','efg','ijk’] • Sequence of numbers - [1,2,3,4,5,6,7,8,9] • Sequence of mix data – [‘Suvi’, 4, “LKG”, “Bennett University”, 98.5 Sequence of numbers can also be generated as: • range(start, end, difference) • range(3) = (0,1,2) • range(1,5) = (1,2,3,4) • range(3,9,2) = (3, 5, 7) • range(9,2,-1) = (9,8,7,6,5,4,3) • range(9,2,1) = []
  • 35. For Loop: What will be the output? 1. 2. 3. 4. 5.
  • 36. For Loop: Answers to Previous Questions 1 2 3 4 5
  • 37. •Let one grain of wheat be placed on the first square of a chessboard, two grains on the second square, four grains on the third square, eight grains on the fourth square, and so on until all square are filled in chessboard. what will be the total weight in ton of grains on whole 8×8 chessboard? If 15432 grains in one kg and 907.18 kg in one ton then. Problem Exercise 2
  • 41. Nested Loop • Loop inside a loop a is called nested loop. • Example:
  • 42. Nested Loop: What will be the output? 1. 2. 3. 4. 5.
  • 43. Find all prime numbers between given two numbers
  • 44. Find first 100 prime numbers start from 2.
  • 45. Find number is Strong or not If the sum of the factorial of the digits in a number is equal to the original number, the number is a strong number.
  • 46. Accept the limit and print the strong numbers from 1 to the given limit.
  • 48. Infinite loop • An infinite loop is an iterative control structure that never terminates (or eventually terminates with a system error). • Infinite loops are generally the result of programming errors. • For example: if the condition of a while loop can never be false, an infinite loop will result when executed.
  • 49. Loop Control Statements • Break Statement: Terminates the loop statement and transfers execution to the statement immediately following the loop. • Continue Statement: Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating. • Pass Statement:The pass statement in Python is used when a statement is required syntactically but you do not want any command or code to execute. Use of pass in if: a = 33 b = 200 if b > a: pass Example: for letter in 'Python’: if letter == 'h’: pass print('This is pass block’) print('Current Letter :', letter) print(“Loop Ended!“) Output: Current Letter : P Current Letter : y Current Letter : t This is pass block Current Letter : h Current Letter : o Current Letter : n Loop Ended
  • 50. Break and Continue: Examples • Break Statement: • Continue Statement: Ex.1: fruits = ["apple", "banana", "cherry"] for x in fruits: print(x) if x == "banana": break Output: apple banana Ex.2: fruits = ["apple", "banana", "cherry"] for x in fruits: if x == "banana": break print(x) fruits = ["apple", "banana", "cherry"] for x in fruits: if x == "banana": continue print(x) Output: apple cherry
  • 51. MCQs 1. A while loop continues to iterate until its condition becomes false. a) TRUE b) FALSE 2. A while loop executes zero or more times. a) TRUE b) FALSE 3. All iteration can be achieved by a while loop. a) TRUE b) FALSE 4. An infinite loop is an iterative control structures that, a) Loops forever and must be forced to terminate b) Loops until the program terminates with a system error c) Both of the above 5. The terms definite loop and indefinite loop are used to indicate whether, a) A given loop executes at least once b) The number of times that a loop is executed can be determined before the loop is executed. c) Both of the above 6. A Boolean flag is, a) A variable b) Has the value True or False c) Is used as a condition for control statements d) All of the above
  • 52. MCQs: Answers 1. A while loop continues to iterate until its condition becomes false. a) TRUE b) FALSE 2. A while loop executes zero or more times. a) TRUE b) FALSE 3. All iteration can be achieved by a while loop. a) TRUE b) FALSE 4. An infinite loop is an iterative control structures that, a) Loops forever and must be forced to terminate b) Loops until the program terminates with a system error c) Both of the above 5. The terms definite loop and indefinite loop are used to indicate whether, a) A given loop executes at least once b) The number of times that a loop is executed can be determined before the loop is executed. c) Both of the above 6. A Boolean flag is, a) A variable b) Has the value True or False c) Is used as a condition for control statements d) All of the above