MCQ Python
MCQ Python
Set is a
Ordered collection
Have unique value
Can’t be modified
Both (a) and (b)
2. To create an empty set
{}
Set ()
[]
()
3. Print (‘Good \\ Morning ')
Good \\ morning
Good \ Morning
GoodMorning
None of the above
4. Eval (“2**8”)
256
Error
16
None of the above
5. S=”good morning”
S=[-2:2]
‘Ninrom doo’
''
Error
None of the above
6. Read - only list is
Tuple
List
Dictionary
Set
7. Nums=set ([0,1,2,3,4,5])
Nums.remove(6)
Print (Nums)
{0,1,2,3,4}
Key error
[0,1,2,3,4]
None of the above
8. A=set ()
A.add([“a”,”b”,”c”,”d”])
Error
{“a”,”b”,”c”,”d”}
[a,b,c,d]
None of the above
9. S=”queen”
Print (s[ : :0]
Value error
‘queen’
Ueen
None of the above
10. Str=”hello”
Val=100
Print (str+val)
Hello100
Type error
Hello 100
None of the above
11. Which of the following is a correct variable
-abc
A3bc
8abc
Ab$c
12. 9.0//2.0
4
4.0
Both (a)and (b)
None of the above
13. _ _python
Private variable
Magic variable
Protected variable
None of the above
14. A=true
Print (A)
true
Error
1
None of the above
15. B=1.2+0b111j
Print (b)
Invalid
1.3
1.2
None of the above
16. A=True
B=False
Print (A*B)
1
0
Value error
None of the above
17. Which of the following declarations is incorrect
_x = 2
__x = 3
__xyz__ = 5
None of these
18. Print(0xA + 0xB + 0xC)
What will be the output of this statement?
33
63
0xA + 0xB + 0xC
None of the above
19. X = ‘pqrs’
For i in range(len(x)):
X[i].upper()
Print (x)
Which of the following is the correct output of this program?
PQRS
Pqrs
Qrs
None of the above
20. Which of the following Python statements will result in the output: 6?
A = ([[1, 2, 3],[4, 5, 6], [7, 8, 9]])
A) A[2][1]
B) A[1][2]
C) A[3][2]
D) A[2][3]
21. What will be the output of the following Python program?
While I < 5:
Print(i)
I += 1
If I == 3:
Break
Else:
Print(0)
A) error
B) 0 1 2 0
C) 0 1 2
D) none of the mentioned
22. x=45
y=repr(x)+”a”
Print (y)
Integer can’t be added with string
45a
42
None of the above
23. Which of the following is not true about dictionary
It is an unorder collection of data
Key and value both are mutuable
Each key must have unique value
Enclosed within {}
24. What will be the output of the following code snippet?
Print(2**3 + (5 + 6)**(1 + 1))
129
8
121
None of the above
25. What will be the output of the following code snippet?
A = [1, 2, 3]
A = tuple(a)
A[0] = 2
Print(a)
[2, 2, 3]
(2, 2, 3)
(1, 2, 3)
Error
26. Which of the following concepts is not a part of Python?
Pointers
Loops
Dynamic Typing
All of the above.
27. What will be the output of the following code snippet?
A=3
B=1
Print(a, b)
a, b = b, a
Print(a, b)
31 13
31 31
13 13
13 31