Q1. Is Python case-sensitive when dealing with identifiers?
(a) yes
(b) no
(c) machine dependent
(d) none of the mentioned
Q2. What is the maximum possible length of an identifier?
(a) 31 characters
(b) 63 characters
(c) 79 characters
(d) none of the mentioned
Q3. Which of the following is invalid?
(a) _a = 1
(b) a = 1
(c) str = 1
(d) none of the mentioned
Q4. Which of the following is an invalid variable?
(a) my_string_1
(b) 1st_string
(c) foo
(d) _
Q5. Which of the following is not a keyword?
(a) eval
(b) assert
(c) nonlocal
(d) pass
Q6. All keywords in Python are in
(a) lower case
(b) UPPER CASE
(c) Capitalized
(d) None of the mentioned
Q7. Which of the following is true for variable names in Python?
(a) unlimited length
(b) all private members must have leading and trailing underscores
(c) underscore and ampersand are the only two special characters allowed
(d) none of the mentioned
Q8. Which of the following is an invalid statement?
(a) abc = 1,000,000
(b) a b c = 1000 2000 3000
(c) a,b,c = 1000, 2000, 3000
(d) a_b_c = 1,000,000
Q9. Which of the following cannot be a variable?
(a) init
(b) in
(c) it
(d) on
Q10. What is the output of print 0.1 + 0.2 == 0.3?
(a) True
(b) False
(c) Machine dependent
(d) Error View
Q11. Which of the following is not a complex number?
(a) k = 2 + 3j
(b) k = complex(2, 3)
(c) k = 2 + 3l
(d) k = 2 + 3J
Q12. What is the type of inf?
(a) Boolean
(b) Integer
(c) Float
(d) Complex
Q13. What does ~4 evaluate to?
(a) -5
(b) -4
(c) -3
(d) +3
Q14. What does ~~~~~~5 evaluate to?
(a) +5
(b) -11
(c) +11
(d) -5
Q15. Which of the following is incorrect?
(a) x = 0b101
(b) x = 0x4f5
(c) x = 19023
(d) x = 03964
Q16. What is the result of cmp(3, 1)?
(a) 1
(b) 0
(c) True
(d) False
Q17. Which of the following is incorrect?
(a) float(‘inf’)
(b) float(‘nan’)
(c) float(’56’+’78’)
(d) float(’12+34′)
Q18. What is the result of round(0.5) – round(-0.5)?
(a) 1.0
(b) 2.0
(c) 0.0
(d) None of the mentioned
Q19. What does 3 ^ 4 evaluate to?
(a) 81
(b) 12
(c) 0.75
(d) 7
Q20. Which of the following statements create a dictionary?
(a) d = {}
(b) d = {“john”:40, “peter”:45}
(c) d = {40:”john”, 45:”peter”}
(d) All of the mentioned
Q21. What will be the output of the following Python code snippet?
d = {"john":40, "peter":45}
"john" in d
(a) True
(b) False
(c) None
(d) Error
Q22. What will be the output of the following Python code snippet?
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45} d1 == d2
(a) True
(b) False
(c) None
(d) Error
Q23. What will be the output of the following Python code snippet?
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45} d1 > d2
(a) True
(b) False
(c) Error
(d) None
Q24. Which of the following is a Python tuple?
(a) [1, 2, 3]
(b) (1, 2, 3)
(c) {1, 2, 3}
(d) {}
Q25. Suppose t = (1, 2, 4, 3), which of the following is incorrect?
(a) print(t[3])
(b) t[3] = 45
(c) print(max(t))
(d) print(len(t))
Q26. What will be the output of the following Python code?
>>>t=(1,2,4,3)
>>>t[1:3]
(a) (1, 2)
(b) (1, 2, 4)
(c) (2, 4)
(d) (2, 4, 3)
Q27. What will be the output of the following Python code?
>>>t=(1,2,4,3)
>>>t[1:-1]
(a) (1, 2)
(b) (1, 2, 4)
(c) (2, 4)
(d) (2, 4, 3)
Q28. What will be the output of the following Python code?
>>>t = (1, 2, 4, 3, 8, 9)
>>>[t[i] for i in range(0, len(t), 2)]
(a) [2, 3, 9]
(b) [1, 2, 4, 3, 8, 9]
(c) [1, 4, 8]
(d) (1, 4, 8)
Q29. What will be the output of the following Python code?
d = {"john":40, "peter":45}
d["john"]
(a) 40
(b) 45
(c) “john”
(d) “peter”
Q30. What will be the output of the following Python code?
>>>t = (1, 2)
>>>2 * t
(a) (1, 2, 1, 2)
(b) [1, 2, 1, 2]
(c) (1, 1, 2, 2)
(d) [1, 1, 2, 2]
Ans:
1. A
2. D
3. D
4. B
5. A
6. D
7. A
8. B
9. B
10.B
11.C
12.C
13.A
14.A
15.D
16.A
17.D
18.B
19.D
20.D
21.A
22.B
23.C
24.B
25.B
26.C
27.C
28.C
29.A
30.A