1. Which of the following is the correct syntax for an if statement?
if x > 10: print("x is greater than 10")
if (x > 10) { print("x is greater than 10") }
if x > 10 print "x is greater than 10"
2. What is the result of the following code?
x = 5
if x < 10:
print("Less than 10")
else:
print("10 or more")
Less than 10
10 or more
Error
3. Which logical operator is used to check if both conditions are true?
||
!
and
4. How do you negate a condition in Python?
not condition
!condition
~condition
5. Which statement is used to handle multiple conditions in Python?
if and else
if, elif and else
if or else
6. What is the output of the following code?
x = 10
if x > 5:
print("A")
elif x > 10:
print("B")
print("C")
A
B
C