Question 1
Which loop is used when the number of iterations is known in advance?
Question 2
How can you create a range of number from?
Question 3
What does the for keyword indicate in a for loop?
Question 4
What is the output of the following code snippet?
x = 0
while x < 5:
print(x, end=)
x += 1
Question 5
What is the output of the following code snippet?
x = 3
y = 5
if x > y:
print(x is greater)
elif x < y:
print("y is greater")
else:
print("x and y are equal")
Question 6
What is the purpose of the pass statement in a loop?
Question 7
What is the output of the following code snippet?
x = o
while x < 5:
print(x)
x += 2
Question 8
What is the result of the expression?
Question 9
Which loop executes as long as the given condition is true?
Question 10
What does the break statement do?
Question 11
What does the expression evaluate to?
Question 12
How can you represent greater than or equal to in python?
Question 13
What is the output of the following code snippet?
x = 5
y = 10
if x > 0 and y > 5:
print(Both conditions are true)
else:
print("At least one condition is false")
Question 14
How can you create an infinite loop in python?
Question 15
What is the output of the following code snippet?
x = 6
if x % 2 == 0:
print(Even)
elif
x % 3 == 0:
print(divisible by 3)
else:
print("Neither even nor divisible by 3")
Question 16
Which of the following is not a comparison operator in python?
Question 17
What is the output of the following code snippet?
x = 5
if x == 5:
print(x is 5)
else:
print(x is not 5)
Question 18
Which of the following is used to repeat a block of code a specific number of times?
Question 19
Which of the following is used to exit the current iteration and move to the next one?
Question 20
Which of the following is an infinite loop?
Question 21
What is the output of the following code snippet?
x = 8
if x % 2 == 0:
print(Even)
if x % 3 == 0:
print(Divisible by 3)
Question 22
What is the purpose of the continue statement?
Question 23
What is the output of the following code snippet?
x = 10
if x > 5 and x < 15:
print(In range)
else:
print("Out of range")
Question 24
How can you create a range of even numbers from 2 to 20?
Question 25
What does the range( ) function return?
Question 26
How can you exit a loop prematurely when a certain condition is met?
Question 27
What is the output of the following code snippet?
x = 7
if x % 2 == 0:
print(Even)
elif
x % 3 == 0:
print(divisible by 3)
else:
print(Neither even nor divisible by 3)
Question 28
In Python, how do you represent not equal?
Question 29
What is the purpose of flow control in programming?
Question 30
Which loop is used when you want to iterate over a sequence of element in python?
Question 31
Which of the following is not a python flow control structure?
Question 32
How many times will the following loop execute?
for i in range(5):
print(I)
Question 33
What is the syntax for an if statement in python?
Question 34
What is the output of the following code snippet?
x = 5
if x > 0:
print(Positive)
else:
print("Non-positive")
Question 35
What is the value of expression?
Question 36
What is the purpose of the elif statement in an if-else chain?
Question 37
What is the result of the expression?
Question 38
What does the continue statement do in a loop?
Question 39
What is the output of the following code snippet?
x = 7
if x % 2 == 0:
print(Even)
else:
print(Odd)
Question 40
What is the output of the following code snippet?
x = 2
y =3
if x == 2 or y == 2:
print(At least one variable is 2)
else:
print(Neither variable is 2)
Question 41
Which of the following is an example of a compound condition?
Question 42
What is the purpose of the pass statement in python?
Question 43
Which of the following is a valid way to write a ternary conditional expression in python?
Question 44
Which keyword is used to introduce the else part of an if else statement?
Question 45
What does the else statement do in a loop?
Question 46
How can you iterate over the keys of a dictionary using a for loop?
Question 47
Which operator is used for exponentiation in python?
Question 48
How can you iterate over the values of a dictionary using a for loop?
Question 49
What is the output of the following code snippet?
x = 3
y = 7
if x > y:
print(x is greater than y)
else:
print(x is less than or equal to y)
Question 50
What is the result of the expression ?