COMPUTER Flashcards

1
Q

What is control flow in a program?

A

The order in which the program’s code executes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What regulates the control flow of a Python program?

A

Conditional statements, loops, and function calls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the three types of control structures in Python?

A
  • Sequential
  • Selection
  • Repetition
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are sequential statements?

A

A set of statements whose execution happens in a sequence.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What happens if there is a logic error in sequential statements?

A

The complete source code execution will break.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are selection statements also known as?

A

Decision control statements or branching statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What do selection statements allow a program to do?

A

Test several conditions and execute instructions based on which condition is true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the purpose of an IF statement?

A

To run a particular code only when a certain condition is met.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does an IF-ELSE statement do?

A

Executes the body of if if the test condition is True; otherwise, executes the body of else.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the function of an IF-ELIF-ELSE statement?

A

To conditionally execute a statement or a block of statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a repetition statement used for?

A

To repeat a group (block) of programming instructions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the two types of loops in Python?

A
  • For loop
  • While loop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the purpose of a FOR loop?

A

To iterate over a sequence such as a list, tuple, dictionary, or set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the syntax of a Python FOR loop?

A

for iterating_var in sequence: statement(s)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the WHILE loop do?

A

Repeatedly executes a target statement as long as the specified boolean expression is true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the syntax of a while loop?

A

while expression: statement(s)

17
Q

What indicates the start of an indented block in a loop?

A

A colon (:) at the end of the loop header.

18
Q

What happens when the boolean expression in a while loop becomes false?

A

The program control passes to the line immediately following the loop.

19
Q

What is an infinite loop?

A

A loop that continues to run and doesn’t stop unless forcefully stopped.

20
Q

True or False: A while loop can only execute once.

21
Q

Fill in the blank: A _______ statement is used to repeat a group of programming instructions.

A

repetition