MCQ of Python
MCQ of Python
Show Answer
Show Answer
Q3. Which shortcut command is used to start a new script window in Python IDLE
A. Ctrl+O
B. Ctrl+ N
C. Ctrl+X
D. ctrl+K
Show Answer
Q4. Which shortcut command is used to run pyton script in Python IDLE
A. F3
B. F5
C. F1
D. F6
Show Answer
Q5. What data type is the object below ? L = [1, 23, ‘hello’, 1]
A. List
B. Dictionary
C. Tuple
D. Array
Show Answer
Show Answer
Q7. What is the output of the following program :
defmyfunc(a):
a=a+2
a=a*2
return a
printmyfunc(2)
A. 2
B. 16
C. 8
D. Indentation error
Show Answer
Show Answer
fruits = [“apple”,”banana”,”cherry”]
for x in fruits:
print(x)
A) “apple”, “banana”, “cherry”
b) “a”, “b”,”c”
c) 0,1,2
d) None of the above
Show Answer
Show Answer
Show Answer
Show Answer
Show Answer
for i in range(10):
print(i)
a) 0,1,2,3,4,5,6,7,8,9
b) 1,2,3,4,5,6,7,8,9,10
c) 10
d) None of the abobe
a) 0,1,2,3,4,5
b) 0,1,2,3,4
c) 1,2,3,4
d) None of the above
Show Answer
true= False
while(true):
print(‘I am confused”)
else:
print( “why confused”)
a) I am confused
b) Why confused
c) No output
b) Both a and b
Show Answer
i = -3
while (i)
print(‘Hello my dear’)
Show Answer
How to find the last element of list in Python? Assume `bikes` is the name of list.
(A) bikes[0]
(B) bikes[-1]
(C) bikes[lpos]
(D) bikes[:-1]
What is correct syntax to copy one list into another?
(A) listA = listB[]
(B) listA = listB[:]
(C) listA = listB[]()
(D) listA = listB
If a='cpp', b='buzz' then which of the following operation would show 'cppbuzz' as output?
(A) a+b
(B) a+''+b
(C) a+""+b
(D) All of the above
a = 8.6
b=2
print a//b
(A) 4.3
(B) 4.0
(C) 4
(D) compilation error
a = True
b = False
c = True
if not a or b:
print "a"
elif not a or not b and c:
print "b"
elif not a or b or not b and a:
print "c"
else:
print "d"
(A) a
(B) b
(C) c
(D) d
class test:
def __init__(self):
print "Hello World"
def __init__(self):
print "Bye World"
obj=test()
print(chr(ord('b')+1))
(A) b
(B) syntax error
(C) c
(D) b+1
What is PEP8?
PEP8 is a set of coding guidelines in Python language that programmers can use to write
readable code which makes it easy to use for other users.
>>>str="cppbuzz"
>>>str[:3]
(A) uzz
(B) cpp
(C) buzz
(D) cppb
Which of the following data type is used to store values in Key & Value format?
(A) Class
(B) List
(C) Tuple
(D) Dictionary
Which of the following operators is used to get accurate result (i.e fraction part also) in case
of division ?
(A) //
(B) %
(C) /
(D) None of the above
19 % 2 in python
(A) 17
(B) 2
(C) 0
(D) None of these
Select the command to Find and print Data types using the Type command.
name="Hello World"
(A) type(name)
(B) print(type(name))
(C) print(name)
(D) type()
Is Tuple mutable?
(A) Yes
(B) No