Revision Test
1. Which operator is used for addition?
a) +
b) -
c) *
d) /
2. What is the result of the expression 10 % 3?
a) 3
b) 0
c) 1
d) 2
3. Which operator is used for logical AND?
a) &
b) &&
c) ||
d) |
4. Which operator has the highest precedence?
a) *
b) +
c) ()
d) &&
5. Which of the following is a relational operator?
a) =
b) <=
c) ++
d) &
6. What does the operator != represent?
a) Equals
b) Not equals
c) Greater than
d) Less than
7. What is the result of 5 > 3 ?
a) True
b) False
8. What is the value of a after a = 10; a += 5;?
a) 10
b) 15
c) 5
d) 20
9. Which operator is used to subtract one number from another?
a) +
b) *
c) -
d) /
10. What is the result of 10 / 2?
a) 10
b) 2
c) 5
d) 20
11. Which operator is used to increment a variable by 1?
a) ++
b) --
c) +=
d) -=
12. What is the result of the expression 4 * 2 + 3?
a) 11
b) 14
c) 8
d) 7
13. Which of the following is a logical operator ?
a) &&
b) +=
c) <=
d) !=
14. Which operator is used to check equality ?
a) =
b) ==
c) !=
d) +=
15. What is the result of the following expression: 3 + 5 * 2?
a) 13
b) 16
c) 10
d) 8
16. Which of the following is the correct order of precedence for arithmetic
operators?
a) +, -, *, /
b) *, /, +, -
c) +, *, -, /
d) -, +, /, *
17. What is the result of a = 2; b = 3; a *= b;?
a) 2
b) 3
c) 5
d) 6
18. What is the result of the following expression: 7 / 2 in integer division?
a) 3
b) 3.5
c) 4
d) 7
19. What is the result of 4 % 3 ?
a) 0
b) 1
c) 3
d) 4
20. Which of the following is a bitwise operator?
a) &
b) &&
c) +=
d) !=
21. Which operator is used to divide one number by another?
a) +
b) *
c) -
d) /
22. What is the value of a after a = 5; a--;?
a) 5
b) 4
c) 6
d) 3
23. Which operator is used to check if two values are not equal?
a) !=
b) ==
c) >=
d) <=
24. What does the || operator do?
a) Logical AND
b) Logical OR
c) Bitwise AND
d) Bitwise OR
25. What will be the value of the following expression: 1 || 0?
a) True
b) False
26. Which of the following is a unary operator?
a) +
b) ++
c) *
d) &&
27. Which of the following operators is used for bitwise OR?
a) |
b) ||
c) &&
d) &
28. What is the result of the following expression: 5 && 0?
a) 1
b) 5
c) 0
d) True
29. What will be the value of x after the following code: x = 5; x %= 3;?
a) 2
b) 5
c) 3
d) 1
30. What is the result of the expression 6 < 3 || 4 > 2?
a) True
b) False
31. What is the correct way to declare a floating-point variable?
a) int num = 2.5;
b) float num = 2.5;
c) double num = 2.5;
d) char num = 2.5;
32. Which escape sequence is used for a new line?
a) \t
b) \n
c) \\
d) \b
33. Which of the following is NOT a data type?
a) int
b) float
c) boolean
d) double
34. What is the correct file extension for Python files?
a) .pyth
b) .py
c) .pt
d) .txt
35. Which of the following is a valid variable name in Python?
a) 2variable
b) variable@name
c) variable_name
d) variable-name
36. Which keyword is used to define a function in Python?
a) def
b) function
c) func
d) define
37. What is the purpose of the len() function in Python?
a) To calculate the length of an integer
b) To get the number of elements in an iterable
c) To generate random numbers
d) To define a new function
38. What is the output of the following code?
for i in range(3) :
print (i)
a) 1 2 3
b) 0123
c) 0 1 2 3
d) 3 2 1