What will be the output of the following Python code?
l=[1,2,3,4,5] [x&1 for x in l]
l1=[1,2,3] l2=[4,5,6] [x*y for x in l1 for y in l2]
To pick out only the negative numbers from a given list ‘l’, the correct list comprehension statement would be: [x for x in l if x<0].
For example if we have a list l=[-65, 2, 7, -99, -4, 3] >>> [x for x in l if x<0] The output would be: [-65, -99, -4].
s=["pune", "mumbai", "delhi"] [(w.upper(), len(w)) for w in s]
l1=[10, 20, 30] l2=[-10, -20, -30] l3=[x+y for x, y in zip(l1, l2)] l3
import math [str(round(math.pi)) for i in range (1, 6)]
Read the information given below carefully and write a list comprehension such that the output is: [‘e’, ‘o’]
w="hello" v=('a', 'e', 'i', 'o', 'u')
[ord(ch) for ch in 'abc']
t=32.00 for x in t: print(x)
निम्नलिखित Python कोड का आउटपुट क्या होगा?
Write a list comprehension equivalent for the Python code shown below.
for i in range(1, 101): if int(i*0.5)==i*0.5: print(i)
What is the list comprehension equivalent for?
{x : x is a whole number less than 20, x is even} (including zero)
What will be the output of the following Python list comprehension?
[j for i in range(2,8) for j in range(i*2, 50, i)]
l=["good", "oh!", "excellent!", "#450"] [n for n in l if n.isalpha() or n.isdigit()]
A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] A[1]
Which of the following Python statements will result in the output: 6?
A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [A[row][1] for row in (0, 1, 2)]