1 Crore+ students have signed up on EduRev. Have you? Download the App |
How many times will the following loop execute? for i in range(5):
What is the output of the following code?
for i in range(3):
print(i)
else:
print("Loop completed")
Which loop is ideal to use when the number of iterations is unknown?
What is the output of the following code?
num = 6
for i in range(2, num):
if num % i == 0:
print("Not a prime number")
break
else:
print("Prime number")
Which loop construct allows the execution of a set of statements at least once, even if the loop condition is false?
What is the output of the following code?
num = 10
if num % 2 == 0:
print("Even")
else:
print("Odd")
What is the output of the following code?
for i in range(5):
if i == 3:
break
print(i)
else:
print("Loop completed")
What is the output of the following code?
for i in range(2, 10, 3): print(i, end=" ")
What is the output of the following code?
num = 5
for i in range(num):
if i == 3:
continue
print(i, end=" ")
What is the output of the following code?
i = 1
while i < 5:
print(i)
if i == 3:
break
i += 1
What is the output of the following code?
for i in range(5):
if i == 2:
continue
print(i, end=" ")
else:
print("Loop completed")
What is the output of the following code?
num = 10
while num > 0:
print(num, end=" ")
num //= 2
What is the output of the following code?
for i in range(2, 6):
if i % 2 == 0:
continue
print(i, end=" ")
What is the output of the following code?
for i in range(3):
for j in range(2):
print(i + j, end=" ")
What is the output of the following code?
num = 5
for i in range(num):
print(i, end=" ")
if i == 2:
break
What is the output of the following code?
num = 7
for i in range(2, num):
if num % i == 0:
print(i)
break
else:
print("Prime number")
What is the output of the following code?
num = 10
for i in range(2, num):
if num % i == 0:
print("Not a prime number")
break
else:
print("Prime number")