My Report

Python Programming Practice Test 4


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

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

a=[[]]*3
a[1].append(7)
print(a)

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

numbers = [1, 2, 3, 4]

numbers.append([5,6,7,8])

print(len(numbers))

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

>>> a=(2,3,4)
>>> sum(a,3)

4. Write a list comprehension to produce the list: [1, 2, 4, 8, 16……212].

5. Which of the following is the correct expansion of list_1 = [expr(i) for i in list_0 if func(i)]?

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

l=[[1, 2, 3], [4, 5, 6]]
for i in range(len(l)):
	for j in range(len(l[i])):
		l[i][j]+=10
l

7. Is the following Python code valid?

>>> a=(1,2,3,4)
>>> del a

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

l=[1,2,3,4,5]
[x&1 for x in l]

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

a=[10,23,56,[78]]
b=list(a)
a[3][0]=95
a[1]=34
print(b)

10. Which of the following Python statements will result in the output: 6?

A = [[1, 2, 3],
     [4, 5, 6],
     [7, 8, 9]]

 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.