Q. Predict the output.


(i)

LA = [1, 4, 9, 16, 25, 36, 49, 64, 81, 168]

LB = [num/3 for num in LA if num % 3 == 0]

print (LB)


(ii)

[x + y for x in 'ball' for y in 'boy']


(iii)

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

k = [elem1*elem2 for elem1 in li if (elem1-4) > 1 for elem2 in li[:4]]

print (k)


Answer :-

(i)

Output :-

[3.0, 12.0, 27.0]
>>>

(ii)

Output :-

>>> [x + y for x in 'ball' for y in 'boy']
['bb', 'bo', 'by', 'ab', 'ao', 'ay', 'lb', 'lo', 'ly', 'lb', 'lo', 'ly']

>>>

(iii)

Output :-

[6, 12, 18, 24, 7, 14, 21, 28, 8, 16, 24, 32, 9, 18, 27, 36]
>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post