My Report

Python List Test – 2


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. Suppose list1 is [1, 3, 2], What is list1 * 2?

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

3. To remove string "hello" from list1, we use which command?

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

>>>names = ['Amir', 'Bear', 'Charlton', 'Daman']
>>>print(names[-1][-1])

5. Suppose list1 = [0.5 * x for x in range(0, 4)], list1 is:

6. To add a new element to a list we use which command?

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

names1 = ['Amir', 'Bear', 'Charlton', 'Daman']
names2 = names1
names3 = names1[:]

names2[0] = 'Alice'
names3[1] = 'Bob'

sum = 0
for ls in (names1, names2, names3):
    if ls[0] == 'Alice':
        sum += 1
    if ls[1] == 'Bob':
        sum += 10

print sum

8. Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)?

9. To insert 5 to the third position in list1, we use which command?

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

>>>list1 = [11, 2, 23]
>>>list2 = [11, 2, 2]
>>>list1 < 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.