Select the correct answerThe single line equivalent of the following Python code?c=[10, 22, 30, 45, 54]def codetantra(a): return a<0ct=filter(codetantra, c)print(list(ct))Optionsfilter(lambda x:x<0, l)filter(reduce x<0, l)filter(lambda x, y: x<0, l)reduce(x: x<0, l)
Question
Select the correct answerThe single line equivalent of the following Python code?c=[10, 22, 30, 45, 54]def codetantra(a): return a<0ct=filter(codetantra, c)print(list(ct))Optionsfilter(lambda x:x<0, l)filter(reduce x<0, l)filter(lambda x, y: x<0, l)reduce(x: x<0, l)
Solution
The correct answer is filter(lambda x:x<0, l)
Similar Questions
Select the correct answerWhat will be the output of the following Python code?c=[10, -22, -39, 43, 55]def codetantra(x): return x<-1ct=map(codetantra, c)print(list(ct))Options[False, False, False, False, False][True, False, False, True, True][True, True, True, True, True][False, True, True, False, False]
What is the output of the code:mylist =[0, 5, 2, 0, 'codetantra', '', []]print(list(filter(bool, mylist)))Options[5, 2, 'codetantra'][0, 5, 2, 0, ‘codetantra’, ”, []][0, 0, ]Error
Select the correct answerWhat will be the output of the following Python code?>>>ct1="codetantra">>>ct1[:3]>>>Optionscododetacodetantrade
answerWhat will be the output of the following Python code?l=[1, 0, 2, 0, 'hello', '', []]list(filter(bool, l))Options[1, 0, 2, ‘hello’, ”, []][1, 2, ‘hello’]Error[1, 0, 2, 0, ‘hello’, ”, []]
Select the correct answerWhat will be the output of the following Python code snippet?ct = 'code'for i in range(len(ct)): i.upper()print (ct)Optionsc o d eerror0 1 2 3none of the mentioned
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.