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].
What will be the output of the following Python code?
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)