Question 1
Which statement is used to a execute a block of code after the loop has finished executing all iterations, but only if the loop completed normally.( not terminated by a break statement)?
Question 2
Which statement is used to remove a variable or an item from a list in python?
Question 3
Which statement is used to raise an exception in python?
Question 4
What will be the output of the following code?
for i in range(5):
print(i, end= )
else:
print(Loop completed)
Question 5
What will be the output of the following code?
numbers = [1, 2, 3, 4, 5]
for num in numbers:
if num == 3:
del numbers[3]
print(numbers)
Question 6
What is the purpose of the else block in a loop in python?
Question 7
What will be the output of the following code?
x=5
if x>10:
print(Greater than 10)
else:
del x
print(x)
Question 8
What is the purpose of the del statement in python?
Question 9
What will be the output of the following code?
try:print(Hello, end=)
except:print(Error)
else:print(World)
Question 10
What is the purpose of the else block in try-except statement in python?