My Report

Python List Test – 3


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?

>>>"Welcome to Python".split()

2. Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.reverse()?

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

myList = [1, 5, 5, 5, 5, 1]
max = myList[0]
indexOfMax = 0
for i in range(1, len(myList)):
    if myList[i] > max:
        max = myList[i]
        indexOfMax = i

>>>print(indexOfMax)

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

>>>list("a#b#c#d".split('#'))

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

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

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

def f(values):
    values[0] = 44

v = [1, 2, 3]
f(v)
print(v)

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

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

myList = [1, 2, 3, 4, 5, 6]
for i in range(1, 6):
    myList[i - 1] = myList[i]

for i in range(0, 6): 
    print(myList[i], end = " ")

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

>>>list1 = [1, 3]
>>>list2 = list1
>>>list1[0] = 4
>>>print(list2)

 

Start practicing “1000 MCQs on Python”, and once you are ready, you can take tests on all topics by attempting our “Python Test Series”.

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.