Logo

Python Questions Set 85:

Quiz Mode

Suppose list1 is [1, 3, 2], What is list1 * 2? 

1
2
3
4

Solution:

What will be the output of the following Python code?

print('a'.maketrans('ABC', '123'))

1
2
3
4

Solution:

What will be the output of the following Python code?


x = (i for i in range(3))  

for i in x:  

    print(i)

1
2
3
4

Solution:

What is the output of the given code?


List=['A','b','e','k','u','s']


sList=List[4:6]


    

print(sList)

1
2
3
4

Solution:

 

What is the output of the following code?

while 4 == 4:
   print('4')

1
2
3
4

Solution:

 

o=0

e=0

n=5

for i in range(n):

   x=int(input())

   if x%2 == 1:

       e+=1

   else:

       o+=1

print(o)


if input is 

4

5

6

7

8

then what is the output of the above code ____?

Solution:

What will be the output of the following Python code?

def getMonth(m):
if m < 1 or m > 12:
raise ValueError("Invalid")
print(m)
getMonth(6)

1
2
3
4

Solution:

 Which of the following statements is true? 

1
2
3
4

Solution:

 

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

 a={1:"A",2:"B",3:"C"}

 print(a.setdefault(3)) 

1
2
3
4

Solution: