Logo

Python Questions Set 41:

Quiz Mode

 

N=3
sum=0
for i in range(1,N+1):
    sum+=pow(i,i)
print(sum)

Solution:

What is PIP ?

1
2
3
4

Solution:

Given the following Python code:

mylist=[5,4,3,"hi"]

mylist=sorted(mylist)

print(mylist)

1
2
3
4

Solution:

 How to get the last element of the list in python? Suppose we have a list with name arr, contains 5 elements. 

1
2
3
4

Solution:

 

What will be the output of the following Python code?


 nums = set([1,1,2,3,3,3,4,4])

 print(len(nums)) 

1
2
3
4

Solution:

 

What will be the output of the following Python code?

l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))

1
2
3

Solution:

What will be the output of the following Python code snippet?

print([if i%2==0: i; else: i+1; for i in range(4)])

1
2
3
4

Solution:

Is the following Python code valid?

>>> a=(1,2,3,4)
>>> del a

1
2
3
4

Solution:

Find the output of the following code:

q={'digit':4,'decimal':1.2,'value':24}
q.update({'digit':5})
print(q)
q['decimal']=1.3
q['value']=25

1
2
3
4

Solution:

  If a={5,6,7}, what happens when a.add(5) is executed?
 

1
2
3
4
5
6
7
8

Solution: