Quiz on List Comprehensions
Quiz on List Comprehensions
by
PythonGeeks Team
Boost Your Career with In-demand Skills - Start Now!
0 of 15 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
You must sign in or sign up to start the quiz.
You must first complete the following:
Quiz complete. Results are being recorded.
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0 )
Earned Point(s): 0 of 0 , (0 )
0 Essay(s) Pending (Possible Point(s): 0 )
Show Question
1
Show Question
2
Show Question
3
Show Question
4
Show Question
5
Show Question
6
Show Question
7
Show Question
8
Show Question
9
Show Question
10
Show Question
11
Show Question
12
Show Question
13
Show Question
14
Show Question
15
Review / Skip
Answered
Correct
Incorrect
Question 1 of 15
Which of the following is a feature of list comprehensions?
Question 2 of 15
Which of the following is the output of the following code?
list1=[1,2,3,4,5]
list2=[i%5 for i in list1]
list2
Question 3 of 15
If we have two if statements in the list comprehension, then the output is True iff
Question 4 of 15
Which of the following takes only those string that has digit and also stores the value as int?
list1=[‘1′,’a’,’3′,’d’,’5′]
Question 5 of 15
Which of the following functions cannot be used with lambda functions?
Question 6 of 15
Which of the following is the output of the following code?
list1=[1,-3,4,-8,9,0] list2=[-x if x<0 else x for x in list1] list2
Question 7 of 15
Which of the following gives the output as the cubes of the values from 1 to 10, including 10.
Question 8 of 15
Which of the following is the correct way to use filter function?
Question 9 of 15
Which of the following is the output of the following code?
list1=[1,-2,3]
[[i+j for i in list2] for j in list1]
[2, 4, 5, 9, 10, 1, -1, 1, 2, 6, 7, -2, 4, 6, 7, 11, 12, 3]
Correct
Incorrect
Correct answer
[2, -1, 4, 4, 1, 6, 5, 2, 7, 9, 6, 11,10, 7, 12, 1, -2, 3]
Correct
Incorrect
Correct answer
[[2, 4, 5, 9, 10, 1], [-1, 1, 2, 6, 7, -2], [4, 6, 7, 11, 12, 3]]
Correct
Incorrect
Correct answer
[[2, -1, 4, 4, 1, 6], [5, 2, 7, 9, 6, 11],[10, 7, 12, 1, -2, 3]]
Correct
Incorrect
Correct answer
Question 10 of 15
Which of the following gives the output as [‘a’,’B’,’c’,’D’] if list1=[‘A’,’b’,’C’,’d’]?
Question 11 of 15
Which module should be imported to use reduce() function in lambda functions?
Question 12 of 15
Which of the following is the output of the following code?
list1=[1,-3,0.9,5.6] [int(i) for i in list1]
Question 13 of 15
Which of the following will find the sum of the first 5 natural numbers?
Question 14 of 15
Which of the following is the output of the following code?
[i for i in “ABCDEFG” if i not in “aeiou”]
Question 15 of 15
Which of the following gives the output as True?
Did you like our efforts? If Yes, please give PythonGeeks 5 Stars on Google | Facebook
PythonGeeks Team
The PythonGeeks Team offers industry-relevant Python programming tutorials, from web development to AI, ML and Data Science. With a focus on simplicity, we help learners of all backgrounds build their coding skills.