Professional Documents
Culture Documents
: 9810301034
MCQ CS 083 PYTHON
Set 1
All questions are of 1 mark.
BASIC IOP & OPERATORS
1. Which of the following is a valid identifier: i. >>>not -5 ii. >>>not 5 iii. >>>not 0 iv. >>>not(5-
i. 9type ii. _type iii. Same-type iv. True 1)
2. Which of the following is a relational operator: 13. Give the output of the following code:
i. > ii. // iii. or iv. ** >>>7*(8/(5//2))
3. Which of the following is a logical operator: i. 28 ii. 28.0 iii. 20 iv. 60
i. + ii. /= iii. and iv. in 14. Give the output of the following code: >>>import
4. Identify the membership operator from the math
following: >>> math.ceil(1.03)+math.floor(1.03)
i. in ii. not in iii. both i & ii iv. Only i i. 3 ii. -3.0 iii. 3.0 iv. None of the
5. Which one is a arithmetic operator: above
i. not ii. ** iii. both i & ii iv. Only ii 15. What will be the output of the following code:
6. What will be the correct output of the statement : >>>import math ;>>>math.fabs(-5.03)
>>>4//3.0 i. 5.0 ii. 5.03 iii. -5.03 iv . None of the
i. 1 ii. 1.0 iii 1.3333 iv. None of the above
above 16. Single line comments in python begin with……..
7. What will be the correct output of the statement : symbol.
>>> 4+2**2*10 i. # ii. “ iii. % iv. _
i. 18 ii. 80 iii. 44 iv. None of the 17. Which of the following are the fundamental building
above block of a python program.
8. Give the output of the following code: i. Identifier ii. Constant iii. Punctuators iv.
>>> a,b=4,2 ;>>> a+b**2*10 Tokens
i. 44 ii. 48 iii. 40 iv. 88 18. The input() function always returns a value of
9. Give the output of the following code: …..type.
>>> a,b = 4,2.5 ; >>> a-b//2**2 i. Integer ii. float iii. string iv.
i. 4.0 ii. 4 iii. 0 iv. None of the above Complex
10. Give the output of the following code: 19. ……….. function is used to determine the data type of
>>>a,b,c=1,2,3 ;>>> a//b**c+a-c*a a variable.
i. -2 ii. -2.0 iii. 2.0 iv. None of the above i. type( ) ii. id( ) iii. print( ) iv. str( )
11. If a=1,b=2 and c= 3 then which statement will give 20. The smallest individual unit in a program is known as
the output as : 2.0 from the following: a..
i. a%b%c+1 ii. a%b%c+1.0 iii. a%b%c iv. a%b%c-1 i. Token ii. keyword iii. punctuator iv. identifier
12. Which statement will give the output as : True from
the following :
FLOW OF EXECUTION
21.Which of the following is not a decision making while a>0: print(a)
statement print(“Bye”)
i. if..else statement ii. for statement iii. if-elif i. times ii. Once iii. Infinite iv. None of these
statement iv. if statement 24.What abandons the current iteration of the loop
22.…………loop is the best choice when the number of i. continue ii. stop iii. infinite iv. Break
iterations are known. 25.Find the output of the following python program
ii. while ii. do-while iii. for iv. None of for i in range(1,15,4): print(i, end=’,’)
these i. 1,20,3 ii. 2,3,4 iii. 1,5,10,14 iv. 1,5,9,13
23. How many times will the following code be 26.…………loop is the best when the number of iterations
executed. are not known.
a=5
Page 1 of 9 Computer Science 083 PYTHON pgt.csip.gajedra@gmail.com
MCQ PYTHON By Gajendra Sir Mo. No. : 9810301034
i. while ii. do-while iii. for iv. None of 29.How many times will the following code be executed
these for i in range(1,15,5):
27.In the nested loop ……………..loop must be terminated print(i,end=’,’)
before the outer loop. i. 3 ii. 4 iii. 1 iv. infinite
i. Outer ii. enclosing iii. inner iv. None of 30.Symbol used to end the if statement:
these i. Semicolon(;) ii.Hyphen(-) iii. Underscore( _ ) iv.
28.…………..statement is an empty statement in python. colon(:)
i. pass ii. break iii. continue iv. if
NOTES
ANSWERS
1 ii 2 i 3 iii 4 iii 5 iv 6 ii 7 iii
8 i 9 i 10 i 11 ii 12 iii 13 ii 14 i
15 iii 16 i 17 i 18 iii 19 i 20 i 21 ii
22 iii 23 iii 24 iv 25 iv 26 i 27 iii 28 i
29 i 30 iv 31 iii 32 iv 33 iv 34 i 35 iii
36 i 37 ii 38 i 39 i 40 ii 41 i 42 iii
43 iv 44 iv 45 i 46 iv 47 iii 48 i 49 iii
50 i
Page 3 of 9 Computer Science 083 PYTHON pgt.csip.gajedra@gmail.com
MCQ PYTHON By Gajendra Sir Mo. No. : 9810301034
MCQ CS 083 PYTHON
Set 2
All questions are of 1 mark.
LIST
51. Given the list L=[11,22,33,44,55], write the output of 60. Match the columns: if
print(L[: :-1]). >>>l=list(‘computer’)
i. [1,2,3,4,5] ii. [22,33,44,55] Column A Column B
iii. [55,44,33,22,11] iv. Error in code 1. L[1:4] a. [‘t’,’e’,’r’]
52. Which of the following can 2. L[3:] b. [‘o’,’m’,’p’]
add an element at any index in 3. L[-3:] c. [‘c’,’o’,’m’,’p’,’u’,’t’]
the list? 4. L[:-2] d. [‘p’,’u’,’t’,’e’,’r’]
i. insert( ) ii. append( ) iii. extend() iv. all of these i. 1-b,2-d,3-a,4-c iii. 1-c,2-b,3-a,4-d
53. Which of the following function will return a list ii. 1-b,2-d,3-c,4-a iv. 1-d,2-a,3-c,4-b
containing all the words of the given string? If a list is created as l=[1,2,3,’a’, [‘apple’,’green’], 5,6,7,
i . split() ii. index() i [‘red’,’orange’]]
i i . count() iv. list() then what will be the output of the following
statements:
54.Which of the following statements are True.
61. >>>l[4][1]
a. [1,2,3,4]>[4,5,6]
i. ‘apple’ ii. ‘red’ iii. ‘green’ iv. ‘orange’
b. [1,2,3,4]<[1,5,2,3]
62. If >>>l[8][0][2]
c. [1,2,3,4]>[1,2,0,3] i. ‘d’ ii. ‘r’ iii. ‘e’ iv. ‘o’
d. [1,2,3,4]<[1,2,3,2] 63. >>>l[-1]
i. a,b,d ii. a,c,d iii. a,b,c iv. Only d
i. [‘apple’,’green’] iii. [‘red’,’orange’] ii. [‘red’
55. If l1=[20,30] l2=[20,30] l3=[‘20’,’30’] l4=[20.0,30.0] ] iv. [’orange’]
then which of the following statements will not return 64 >>>len(l)
‘False’: i. 10 iii. 9 ii. 8 iv 11
a. >>>l1==l2 b. >>>l4>l1 c. >>>l1>l2 d. >>> l2==l2 65. What will be the output of the following code:
i. b, c ii. a,b,c iii. a,c,d iv. a,d >>>l1=[1,2,3]
56. If >>>l1=[10,20,30,40,50] >>>l1.append([5,6])
>>>l2=l1[1:4] >>>l1
What will be the elements of list l2: i. [1,2,3,5,6] ii. [1,2,3,[5,6]] iii. [[5,6]] iv. [1,2,3,[5,6]]
i. [10,30,50] ii. [20,30,40,50] iii. [10,20,30] iv. 66. What will be the output of the following code:
[20,30,40] >>>l1=[1,2,3]
57. >>>l=[‘red’,’blue’] >>>l = l + ‘yellow’ >>>l2=[5,6]
What will be the elements of list l: >>>l1.extend(l2)
i. [‘red’,’blue’,’yellow’] ii. [‘red’,’yellow’] iii. >>>l1
[‘red’,’blue’,’yellow’] iv. Error i. [5,6,1,2,3] ii. [1,2,3,5,6] iii. [1,3,5] iv. [1,2,3,6]
58. What will be the output of the following 67. What will be the output of the following code:
code: >>>l1=[1,2,3]
>>>l=[1,2,3,4] >>>l1.insert(2,25)
>>>m=[5,6,7,8] >>>l1
>>>n=m+l i. [1,2,3,25] ii. [1,25,2,3] iii. [1,2,25,3] iv. [25,1,2,3,6]
>>>print(n)
68. >>>l1
i. [1,2,3,5,6,7,8] ii. [1,2,3,4,5,6,7,8] iii. [1,2,3,4][5,6,7,8]
=[10,20,3
iv. Error
0,40,50,60
59. What will be the output of the following code: ,10,20,10]
>>>l=[1,2,3,4] >>>l1.cou
>>>m=l*2 nt(‘10’)
>>>n=m*2 i. 3 ii. 0 iii. 2 iv. 9 69.
>>>print(n)
69. Which operators can be used with list?
i [1,2,3,4,1,2,3,4,1,2,3,4]
i. in ii. not in iii. both (i)&(ii) iv. Arithmetic operator only
ii. [1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4]
iii. [1,2,3,4][4,5,6,7] iv. [1,2,3,4]
Page 4 of 9 Computer Science 083 PYTHON pgt.csip.gajedra@gmail.com
MCQ PYTHON By Gajendra Sir Mo. No. : 9810301034
70. Which of the following function will return the first i. sort() ii. value() iii. index() iv. sorted()
occurrence of the specified element in a list.
NOTES
ANSWERS
51 iii 52 i 53 i 54 iii 55 iv 56 iv
57 iv 58 ii 59 ii 60 i 61 iii 62 i 63 iii
64 iii 65 iv 66 ii 67 iii 68 ii 69 iii 70 iii
71 iv 72 ii 73 ii 74 ii 75 i 76 ii 77 ii
78 iii 79 iii 80 i 81 i 82 iii 83 iii 84 iii
85 ii 86 iv 87 i 88 iii 89 ii 90 i 91 iii
92 i 93 iii 94 i 95 ii 96 i 97 ii 98 iii
99 ii 100 i
Answers: