CT3/P3 Flashcards
What are the types of programming constructs?
Sequence
Selection
Iteration
What is the function of a sequence programming construct?
It is used for the execution of statements or functions one after the other.
What is the function of a selection programming construct?
Selection is used to execute only a particular set of statements if a condition is satisfied.
What is the function of an iteration programming construct?
Iteration is used to execute a particular set of statements repeatedly until a condition is satisfied.
In what ways can iteration statements be created?
By counting how many times the statements are to be executed
By repeatedly executing the statements until a condition is true
By repeatedly executing the statements while a condition is true
What structure is used to count the number of times a statement is to be executed?
“for” structure
What structure is used to execute statements until a condition is met ?
“Repeat until” or “Do while” loop
What structure is used to execute statements while a condition is met?
“While” loop
What iteration structures are available in Python?
‘for’ loop and while loop
What type of programming construct is used to print a multiplication table?
Iteration. For loop
What is the syntax for checking multiple conditions in Python?
if expression1:
statement(s)
elif expression2:
statements(s)
…
else:
statement(s)
What is the syntax for ‘for’ loop in Python?
for num in range( , ):
statement(s)
What is the syntax for while loop in Python?
while (condition):
statement(s)
What is a break statement used for?
Break statement in Python terminates the current loop and resumes operation from the next statement.
What are variables?
Variables are labels that are used to represent values stored in computer memory, whose values can be changed during the execution of a program.