What will be the output of the following Python code?
l=[1,2,3,4,5] [x&1 for x in l]
What will be the output of the following Python code snippet?
a={1:"A",2:"B",3:"C"}
a.setdefault(4,"D")
print(a)
def m(list):
v = list[0]
for e in list:
if v < e: v = e
return v
values = [[3, 4, 5, 1], [33, 6, 1, 2]]
for row in values:
print(m(row), end = " ")
>>>list("a#b#c#d".split('#'))
places = ['Bangalore', 'Mumbai', 'Delhi'] <br class="blank" />places1 = places places2 = places[:] <br class="blank" />places1[1]="Pune" places2[2]="Hyderabad" print(places)
b={4:"D",5:"E"} a.update(b)
>>>import collections >>> b=collections.Counter([2,2,3,4,4,4]) >>> b.most_common(1)
my_string = "hello world" k = [(i.upper(), len(i)) for i in my_string] print(k)
What is the syntax of the following Python code?
>>> a=frozenset(set([5,6,7])) >>> a
>>> a={1,2,3}
>>> b=a >>> b.remove(3)
>>> a
Is the following Python code valid?
>>> a=2,3,4,5 >>> a
x=[[1],[2]] print(" ".join(list(map(str,x))))
numberGames = {}
numberGames[(1,2,4)] = 8
numberGames[(4,2,1)] = 10
numberGames[(1,2)] = 12
sum = 0
for k in numberGames:
sum += numberGames[k]
print len(numberGames) + sum
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)]
>>>t = (1, 2, 4, 3, 8, 9)
>>>[t[i] for i in range(0, len(t), 2)]