A for loop that contains another for statement inside it is called:
- aIterative for loop
- bNested for loop
- cRecursive for loop
- dCompound for loop
103 questions · 12 sections
A for loop that contains another for statement inside it is called:
In a nested for loop, the loop placed inside another for is called the:
In a nested for loop, the loop that surrounds another for is called the:
Which loop completes its full set of iterations first in a nested for structure?
For each single iteration of the outer loop, the inner loop:
The pattern produced by for i in range(1,10): for j in range(1, i+1): print(j, end="_") followed by print() is:
Nested loops are most useful when a programme needs to:
A while loop is used in Python programmes to execute a statement:
The condition of a while loop is verified at:
A while loop will only execute if the given condition is:
A while loop terminates whenever the condition becomes:
If the condition supplied to a while loop is initially false, the body of the loop is executed:
Which symbol is placed after the condition in a Python while statement?
;,:.The number of iterations of a while statement is calculated using:
While loops are often used as alternatives to:
if statementsfor statementsprint statementsimport statementsA loop that never stops because its condition never becomes false is called:
Without an increment or decrement to the counter, a while loop will most likely:
To exit a running while loop intentionally, the loop body should:
In the format CounterInitialization; while Condition: // Statement; CounterDecrement/Increment, the part where the counter starts is the:
The portion of the while loop that decides when to stop iterating is the:
The portion of the while loop that updates the counter on each pass is the:
Statements associated with a while loop continue to execute as long as the condition is:
The statement associated with a while loop is usually a:
A while loop placed inside another while loop is called a:
Which of the following can be placed inside a while loop body?
while loopfor loopif statementThe initial value of the counter variable is set with the appropriate:
In a while loop, the final value of the counter (or the condition for it) is given in the:
The increment or decrement value of the counter variable is defined while:
Which Python statement is missing from count=1 followed by while (count<=3): print('ICT') to avoid an infinite loop?
count=count+1print(count)if count: passreturn countIndentation in a Python while loop body is used to indicate:
In a nested while loop, the inner loop completes:
The keyword used inside an inner while loop to immediately exit it (per the textbook flowchart) is:
In the nested-while flowchart, Block2 is associated with the:
In the nested-while flowchart, Block3 runs:
Which of the following is true about a nested while loop?
if with break can be used to exit the inner loop earlyNested loops let you express problems where:
To display the text ICT 3 times using a while loop, the counter is typically initialized as:
count=0 then while count<3count=1 then while (count<=3)count=3 then while count<=0count=10 then while count==0In the while (count<=3) example, what statement is needed inside the loop to avoid running forever?
print('ICT') onlycount=count+1del countcount=count*0Running the textbook code with count=1, while (count<=3): print('ICT'); count=count+1 prints:
Which line in the loop is responsible for actually showing the word ICT on screen?
count=1while (count<=3):print('ICT')count=count+1If the condition were changed to while (count<=5) with the same counter logic, the text ICT would be displayed:
If the counter increment count=count+1 is removed from the while loop, the code will:
ICT infinitelyICT zero timesWhich Python comparison operator allows the counter value 3 itself to enter the loop body in while (count<=3)?
<<===>=To convert the same task to a for loop, an equivalent header is:
for i in range(0)for i in range(1, 4)for i in range(3, 1)for i in range(-1, 3)The sum of all positive integers from 1 to 100 (the result of the textbook program) is:
In the textbook sum program, the accumulator variable is initialized as:
sum=1sum=0sum=100sum=countThe counter variable in the sum program is initialized as:
count=0count=1count=100count=sumInside the loop, the value of sum is updated with the line:
sum = countsum = sum + countsum = sum * countsum = sum - countThe loop condition used to add numbers up to 100 is:
while count<100while count<=100while count==100while count>100After the loop ends, the program displays the result with:
print(count)print('The sum of the value is ', sum)input(sum)return sumIf the condition were while count<=10 with the same body, the printed sum would be:
If the program forgot to write count=count+1, what would happen?
To compute the sum from 1 to 50 (short-answer task), which condition is correct?
while count<=50while count<50while count==50while count>=50To sum the first 100 positive integers using a for loop instead, an equivalent header is:
for count in range(1, 100)for count in range(1, 101)for count in range(0, 100)for count in range(100, 1)The continue statement in Python is used to:
The format of the continue statement is simply:
continue();continuecontinue : Truedef continue():The continue statement moves the programme pointer to:
The continue statement cannot work directly without:
print and inputif, elif, for, while etc.import statementsThe continue statement is usually used to repeat a loop subject to:
if, elif statementsWhen the condition with which continue is associated is true, the compiler:
continuecontinue (skipping the rest of the loop body that iteration)When the condition associated with continue is false, the compiler:
continuecontinue statement and executes the next statementWhich statement is true about continue?
Which keywords commonly accompany continue to control which iterations are skipped?
ifelifdefThe difference between continue and break is that:
continue skips one iteration; break exits the loop entirelycontinue exits the loop; break skips one iterationcontinue is most useful for:
In the program that prints 1 to 10 except 4, the loop header used is:
for num in range(1, 10, 1)for num in range(1, 11, 1)for num in range(0, 10, 1)while num<=10The condition that triggers the continue statement to skip a number is:
if num == 0:if num == 4:if num > 4:if num != 4:After running the textbook program, which numbers are displayed?
Which keyword is used after the if block in this skip program to print the remaining numbers?
passelsebreakreturnThe print(num, end=" ") call prints each number followed by:
The final print('Used continue to skip printing the value 4') runs:
If if num == 4: continue were replaced with if num == 4: break, the displayed output would be:
When a break statement is found inside a loop, the loop:
The textbook compares break to:
In most cases, the break statement is used together with:
print, inputif, elif, etc.def, classimport, fromWhich of the following best describes break?
After a break exits a loop, execution resumes at:
Inside a nested loop, a break placed in the inner loop will exit:
Which statement is true about break and continue?
break ends the loop completelycontinue skips to the next iterationif conditionsWithout using break, the only other way to leave a while True: loop is to:
whileprintIn the program that prints numbers 0 to 4 then stops, the loop header is:
for i in range(0, 5)for i in range(0, 10)for i in range(1, 10)while i<=10The condition that triggers the break is:
if i == 0:if i == 5:if i > 10:if i < 5:The output of the textbook program is:
The break statement in this program causes the loop to exit when:
i equals 0i equals 5i equals 10If break were replaced with continue while keeping if i == 5, the program would print:
If if i == 5: break were removed, the loop would print:
The pattern of using if together with break lets a programme leave the loop:
Which statements are correct about the role of a translator?
In Python, which function is used to display text on the monitor?
printf()print()printprintln()Which of the following is a valid Python variable name?
9810$variableprintNational_IDIn Python, if y = int(2.8), what will print(y) output?
In Python, given a = 5, b = 2, and y = a % b, what will print(y) output?
Consider for i in range(1,6): print('ICT'). How many times will ICT be displayed?
Which of the following are valid Python identifiers?
9810$variableNational_IDWhy is print (without parentheses) not a function call in Python 3?
print is a reserved word with no behaviourprint must be called as print() with parenthesesprint only works inside a classA compiler converts the entire source program into machine code:
An interpreter converts instructions into machine code:
The low-level binary code that the CPU directly understands is called:
Which Python program correctly displays NCTB three times using a while loop?
count=1 then while count<=3: print('NCTB'); count=count+1count=0 then while count==3: print('NCTB')count=3 then while count<0: print('NCTB')print('NCTB' * 0)The sum of all positive integers from 1 to 50 is:
To compute the sum from 1 to 50 via a while loop, the loop header is:
while count<50while count<=50while count==50while count>=50Inside the 1-to-50 sum loop, which line accumulates the running total?
sum = countsum = sum + countcount = count + sumsum = sum - countWhich Python statements are used for loop control?
forwhilecontinue / break / pass