My Report

Python List Comprehension Test – 1


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 snippet?

print([i.lower() for i in "HELLO"])

2. What is the output of print(k) in the following Python code snippet?

k = [print(i) for i in my_string if i not in "aeiou"]
print(k)

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

my_string = "hello world"
k = [(i.upper(), len(i)) for i in my_string]
print(k)

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

k = [print(i) for i in my_string if i not in "aeiou"]

5. What will be the output of the following Python code snippet?

x = [i**+1 for i in range(3)]; print(x);

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

print([[i+j for i in "abc"] for j in "def"])

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

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

print([if i%2==0: i; else: i+1; for i in range(4)])

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

print([i+j for i in "abc" for j in "def"])

10. Which of the following is the same as list(map(lambda x: x**-1, [1, 2, 3]))?


 

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.