Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The While loop will execute until the expression is _____. If the Break statemen

ID: 3665756 • Letter: T

Question

The While loop will execute until the expression is _____.

If the Break statement in a While loop is executed in the _____ statements, the loop terminates _____ [with; without] executing the Else clause’s statements.

If the Continue statement in a While loop is executed in _____ statements, the remaining statements are skipped and go back to _____.

Statements in a For loop will execute _____.

If the Continue statement in a For loop is executed, the remaining _____ statements are skipped and continue with _____ or _____.

range(1,10) returns _____.

range(1,10,2) returns _____.

The number of times the For loop is executed is controlled by _____.

The number of times the While loop is executed is controlled by _____.

The program below will return _____.

a =3
while a < 10:
a = a + 1
if a > 5: continue
print a
print “done”

Explanation / Answer

The While loop will execute until the expression is true.

If the Break statement in a While loop is executed in the loop statements, the loop terminates without executing the Else clause’s statements.

If the Continue statement in a While loop is executed in loop statements, the remaining statements are skipped and go back to the testing expression.

Statements in a For loop will execute for the given number of times.

If the Continue statement in a For loop is executed, the remaining loop statements are skipped and continue with the next item or with the else clause.


range(1,10) returns 1,2,3,4,5,6,7,8,9.

range(start,end) returns values from start to end-1.

range(1,10,2) returns 1,3,5,7,9.

range(start,end,diff) returns the value start to end-1 with a differance =diff in between them

The number of times the For loop is executed is controlled by condition of the expression.

The number of times the While loop is executed is controlled by condition of the expression.

The program below will return 4,5 and done.

a =3
while a < 10:
a = a + 1
if a > 5: continue
print a
print “done”

we start with a=3,

in while loop a=3<10 evalutes to true thus it gets incremented to 4

after this if condition is evaluated to false because 4 is not greater than 5 thus prints the value of a =4

Similarl scenario happens for second iteration and prints value of a =5

in third, iteration we start with a=5, while condition evaluates true and if condition also evalutes to be true thus it gets back to while condition . and after while condition gets false it prints "done"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote