0% found this document useful (0 votes)
10 views

Assignment 1 Python MCQ-4.5.24

Uploaded by

srinu709
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Assignment 1 Python MCQ-4.5.24

Uploaded by

srinu709
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SRM Institute of Science and Technology

Directorate of Distance Education


Department of Computer Applications
MCA – II Semester
Assignment I(MCQ)

Course titile: Python Programming


Course Code: MCAD2221
Max Marks :25

1) What is the data type of X in X = [12.12, 13, 'cppbuzz']

(A) Tuple
(B) Array
(C) Dictionary
(D) List

2) Which of the following data type is used to store values in Key & Value format?
A) Class
(B) List
(C) Tuple
(D) Dictionary

3) a = lambda x,y : x+y


print(a(5, 6))
A) 11
B) 12
C) 10
D) 8

4) a=" python programming"


print(a.split())

A) [‘python’,’programming’]
B) ‘python’,’programming’
C) [‘python’]
D) [‘programming’]

5) a = 4.5
b=2
print a//b

A)2.0
B)2
C)error
D)2.5
6.)What is the output for −
S = [['him', 'sell'], [90, 28, 43]]
S[0][1][1]
A ) 'e'
B ) 'i'
C )'90'
D )h'

7) Syntax error in python is detected by _________at _______


A - compiler/ compile time
B - interpreter/ run time
C - compiler/ run time
D - interpreter/ compile time
8) What command is used to insert 6 in a list ‘‘L’’ at 3rd position ?
A - L.insert(2,6)
B - L.insert(3,6)
C - L.add(3,6)
D - L.append(2,6)

9.) Which of the following symbols are used for comments in Python?

(A) //
(B) ''
(C) /**/
(D) #

10) Which of the following is correct way to declare string variable in Python?

(A) fruit = 'banana'


(B) fruit = "banana"
(C) fruit = banana
(D) fruit = (banana)

11) Python allows string slicing. What is the output of below code:
s='cppbuzz chicago'
print(s[3:5])

(A) pbuzz
(B) buzzc
(C) bu
(D) None of these

12) 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]
13) What is correct syntax to copy one list into another?

(A) listA = listB[]


(B) listA = listB[:]
(C) listA = listB[]()
(D) listA = listB

14) 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

15) Which statement is correct....??

(A) List is mutable && Tuple is immutable


(B) List is immutable && Tuple is mutable
(C) Both are Immutable
(D) Both are Mutable.

16) Which one of the following is not a python's predefined data type?

(A) Class
(B) List
(C) Dictionary
(D) Tuple

17) 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

18) What is the output of the following program?

data = [2, 3, 9]
temp = [[x for x in[data]] for x in range(3)]
print (temp)
a) [[[2, 3, 9]], [[2, 3, 9]], [[2, 3, 9]]]
b) [[2, 3, 9], [2, 3, 9], [2, 3, 9]]
c) [[[2, 3, 9]], [[2, 3, 9]]]
d) None of these

19) What is the output of the following program?


data = [x for x in range(5)]
temp = [x for x in range(7) if x in data and x%2==0]
print(temp)
a) [0, 2, 4, 6]
b) [0, 2, 4]
c) [0, 1, 2, 3, 4, 5]
d) Runtime error

20) What is the output of the following program?

L1 = list()
L1.append([1, [2, 3], 4])
L1.extend([7, 8, 9])
print(L1[0][1][1] + L1[2])
a) TypeError: can only concatenate list (not “int”) to list
b) 12
c) 11
d) 38

21) What is the output of the following program?

D = {1 : 1, 2 : '2', '1' : 1, '2' : 3}


D['1'] = 2
print(D[D[D[str(D[1])]]])
a)2
b) 3
c) ‘2’
d) KeyError

22) What is the output of the following program?

T1 = (1)
T2 = (3, 4)
T1 += 5
print(T1)
print(T1 + T2)
a)TypeError
b) (1, 5, 3, 4)
c) 1 TypeError
d) 6 TypeError

23) What is the output of the following program?

D = dict()
for i in range (3):
for j in range(2):
D[i] = j
print(D)
a) {0: 0, 1: 0, 2: 0}
b) {0: 1, 1: 1, 2: 1}
c) {0: 0, 1: 0, 2: 0, 0: 1, 1: 1, 2: 1}
d) TypeError: Immutable object

24)import sys
L1 = tuple()
print(sys.getsizeof(L1), end = " ")
L1 = (1, 2)
print(sys.getsizeof(L1), end = " ")
L1 = (1, 3, (4, 5))
print(sys.getsizeof(L1), end = " ")
L1 = (1, 2, 3, 4, 5, [3, 4], 'p', '8', 9.777, (1, 3))
print(sys.getsizeof(L1))

a)0 2 3 10
b) 32 34 35 42
c) 48 64 72 128
d) 48 144 192 480

25) Which one of these is floor division?


a) /
b) //
c) %
d) None of the mentioned

You might also like