My Report

Python Programming Mock 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
 10%

Question 1 of 10

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

l=[[1 ,2, 3], [4, 5, 6], [7, 8, 9]]
[[row[i] for row in l] for i in range(3)]

Question 1 of 10

Question 2 of 10

2. Write a list comprehension for number and its cube for l=[1, 2, 3, 4, 5, 6, 7, 8, 9].

Question 2 of 10

Question 3 of 10

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

>>>t=(1,2,4,3)
>>>t[1:-1]

Question 3 of 10

Question 4 of 10

4. Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.extend([34, 5])?

Question 4 of 10

Question 5 of 10

5. To which of the following the "in" operator can be used to check if an item is in it?

Question 5 of 10

Question 6 of 10

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

veggies = ['carrot', 'broccoli', 'potato', 'asparagus']
veggies.insert(veggies.index('broccoli'), 'celery')
print(veggies)

Question 6 of 10

Question 7 of 10

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

names1 = ['Amir', 'Bala', 'Chales']

if 'amir' in names1:
    print(1)
else:
    print(2)

Question 7 of 10

Question 8 of 10

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

def change(var, lst):
    var = 1
    lst[0] = 44
k = 3
a = [1, 2, 3]
change(k, a)
print(k)
print(a)

Question 8 of 10

Question 9 of 10

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

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

Question 9 of 10

Question 10 of 10

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

>>>m = [[x, x + 1, x + 2] for x in range(0, 3)]

Question 10 of 10


 

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.