0% found this document useful (0 votes)
13 views4 pages

Assignment 1

The document contains a series of multiple-choice questions related to Python programming, covering topics such as data types, operations, and syntax. Each question presents a code snippet or expression and asks for the expected output or validity of the code. The questions test the reader's knowledge of Python's features and functionalities.

Uploaded by

Maitra Ambalia
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)
13 views4 pages

Assignment 1

The document contains a series of multiple-choice questions related to Python programming, covering topics such as data types, operations, and syntax. Each question presents a code snippet or expression and asks for the expected output or validity of the code. The questions test the reader's knowledge of Python's features and functionalities.

Uploaded by

Maitra Ambalia
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/ 4

1. Is the following Python code valid?

a=(1,2,3,4)
del a
A No because tuple is immutable
B Yes, the entire tuple is deleted
C Yes, first element in the tuple is deleted
D No, invalid syntax for del method

2.In Python, What is the answer to this expression, 25 % 3 is?


A1
B0
C8
D 8.33

3.What will be output of following commands in Python


list=[’raj’,86,2.23,’john’,70.2]
list2=[456,’john’]
print(list[1:3])
A [’raj’,86,2.23]
B [86,2.23]
C [’raj’,86]
D none of these

4.What will be output of following commands in Python


list1=[’raj’,86,2.23,’john’,70.2]
list2=[456,’john’]
print(list2*2)
A (456,’john’,456,’john’)
B (’john’,’john’)
C (’john’)
D (456,’john’)

5.What type of data is: a=[(2,1),(3,4),(9,9)]?


A Array of tuples
B List of tuples
C Tuples of lists
D Invalid

6.Which of these about a dictionary is false?


A The values of a dictionary can be accessed using keys
B The keys of a dictionary can be accessed using values
C Dictionaries aren’t ordered
D Dictionaries are mutable

7.What will be the output of the following Python code?


a=(8,4,2,7)
a.sort()
a
A (8,4,2,7)
B (2,4,7,8)
C Error, tuple has no attribute sort
D None

8.What is the value of the following expression in Python?


float(22//3+3/3)
A8
B 8.0
C 8.3
D 8.33

9.What will be the output of the following Python code?


not(11<20) and not(11>30)
A False
B True
C Error
D No output

10.What will be the output of the following Python code?


a=np.array([1,2,3],float)
b=np.array([6,3,6],float)
b**a
A array([6.,9.,216.])
B array([1.,8.,243.])
C array([6.,9.,243.])
D none of these

11.What type of language is Python?


A High-level programming language
B Low-level programming language
C Assembly language
D Machine language

12.Which of the following is NOT a Python data type?


A Integer
B String
C Float
D Double

13.Which of the following is used to print a message to the console in Python?


A console.log()
B System.out.println()
C print()
D cout <<

14.What is the output of the following code?


x = 10
y = "20"
print(x + y)
A 30
B 1020
C Error
D None of the above

15.Which of the following is a correct way to create a list in Python?


A myList = [1, 2, 3]
B myList = {1, 2, 3}
C myList = (1, 2, 3)
D myList = "1, 2, 3"

16.What is the output of the following code?

myList = [1, 2, 3]
print(myList[1])
A1
B2
C3
D Error

17.Which of the following is used to get the length of a list in Python?


A len()
B size()
C length()
D count()

18.What is the output of the following code?

myList = [1, 2, 3]
myList.append(4)
print(myList)

A [1, 2, 3, 4]
B [1, 2, 3]
C [4, 3, 2, 1]
D Error

19. Is the following Python code valid?


a=(1,2,3)
b=a.update(4)
Select one:
A. Yes, a=(1,2,3) and b=(1,2,3,4)
B. Yes, a=(1,2,3,4) and b=(1,2,3,4)
C. No because tuples are immutable & ’tuple’ object has no attribute ’update’
D. No because wrong syntax for update() method

20.What will be the output of the following Python expression if x=15 and y=12?
z=x & y
print(z)
Select one:
A. 12
B. b1101
C. 0b1101
D. 1101

21.What will be the output of the following python code?


2** 4 - 5 + 5 ** 1 + 1
a. 7
b. 36
c. 17
d. 6.5

22.What will be the output after Compiling the following code?


a=2
b = 10
c = 15
d=5
a = a ** 3 ** 2
e=a+b*c/d
print(e)
A. 542
B. 542.0
C. 1566.0
D. 94.0

23.What is the maximum length of a Python identifier?


A.32
B.16
C.128
D.No fixed length

You might also like