Quiz-1

Hello PrepSter,

If you find any errors in the quiz below kindly comment in the comment section and we will make it our priority to fix it.

Also if you have a better of the solution to the questions, please do comment them below and if we find it better than ours, we will post it in our website.

Question 1

Time: 00:00:00
What is the output of the code shown?







l=[1,2,3,4,5]
[x&1 for x in l]







[1, 0, 1, 0, 1 ]

[1, 0, 1, 0, 1 ]

[1, 0, 1, 0, 2 ]

[1, 0, 1, 0, 2 ]

[1, 0, 1, 0, 0]

[1, 0, 1, 0, 0]

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 2

Time: 00:00:00
Write the list comprehension to pick out only negative integers from a given list ‘l’.

[x<0 in l]

[x<0 in l]

[x for x<0 in l]

[x for x<0 in l]

[x in l for x<0]

[x in l for x<0]

[x for x in l if x<0]

[x for x in l if x<0]

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 3

Time: 00:00:00
What is the output of the code shown?







s=["pune", "mumbai", "delhi"]
[(w.upper(), len(w)) for w in s]







[(‘PUNE’, 4), (‘MUMBAI’, 6), (‘DELHI’, 5]

[(‘PUNE’, 4), (‘MUMBAI’, 6), (‘DELHI’, 5]

[PUNE, 4, MUMBAI, 6, DELHI, 5]

[PUNE, 4, MUMBAI, 6, DELHI, 5]

Cantsay

Cantsay

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 4

Time: 00:00:00
What is the output of the code shown below?







l1=[2,4,6]
l2=[-2,-4,-6]
for i in zip(l1, l2):
print(i)







2, -2 4, -4 6, -6

2, -2 4, -4 6, -6

[(2, -2), (4, -4), (6, -6)]

[(2, -2), (4, -4), (6, -6)]

(2, -2) (4, -4) (6, -6)

(2, -2) (4, -4) (6, -6)

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 5

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

[x**3 for x in l]

[x**3 for x in l]

[x^3 for x in l]

[x^3 for x in l]

[x**3 in l]

[x**3 in l]

[x^3 in l]

[x^3 in l]

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 6

Time: 00:00:00
. What is the output of the code shown below?







l1=[1,2,3]
l2=[4,5,6]
l3=[7,8,9]
for x, y, z in zip(l1, l2, l3):
print(x, y, z)







4 7 2 5 8 3 6 9

4 7 2 5 8 3 6 9

(1 4 7) (2 5 8) (3 6 9)

(1 4 7) (2 5 8) (3 6 9)

Error

Error

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 7

Time: 00:00:00
What is the output of the code shown below?







l1=[1,2,3]
l2=[4,5,6]
[x*y for x in l1 for y in l2]







[4, 8, 12, 5, 10, 15, 6, 12, 18]

[4, 8, 12, 5, 10, 15, 6, 12, 18]

[4, 10, 18]

[4, 10, 18]

[4, 5, 6, 8, 10, 12, 12, 15, 18]

[4, 5, 6, 8, 10, 12, 12, 15, 18]

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 8

Time: 00:00:00
What is the output of the code shown below?







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







[[1, 4, 7], [2, 5, 8], [3, 6, 9]]

[[1, 4, 7], [2, 5, 8], [3, 6, 9]]

(1 4 7) (2 5 8) (3 6 9)

(1 4 7) (2 5 8) (3 6 9)

Error

Error

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 9

Time: 00:00:00
What is the output of the code shown below?







import math
[str(round(math.pi)) for i in range (1, 6)]







[‘3’, ‘3’, ‘3’, ‘3’, ‘3’, ‘3’]

[‘3’, ‘3’, ‘3’, ‘3’, ‘3’, ‘3’]

[‘3.1’, ‘3.14’, ‘3.142’, ‘3.1416’, ‘3.14159’, ‘3.141582’]

[‘3.1’, ‘3.14’, ‘3.142’, ‘3.1416’, ‘3.14159’, ‘3.141582’]

[‘3’, ‘3’, ‘3’, ‘3’, ‘3’]

[‘3’, ‘3’, ‘3’, ‘3’, ‘3’]

Error

Error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 10

Time: 00:00:00
Write the list comprehension to pick out only negative integers from a given list ‘l’.

[x<0 in l]

[x<0 in l]

[x for x<0 in l]

[x for x<0 in l]

[x in l for x<0]

[x in l for x<0]

[x for x in l if x<0]

[x for x in l if x<0]

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]