Logo

Python Questions Set 57:

Quiz Mode

 Say s=”hello” what will be the return value of type(s)? 

1
2

Solution:

 

 

 What is the type of each element in sys.argv? 

1
2
3
4

Solution:

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

1
2
3
4

Solution:

Which of the following functions is used to identify the instance of a particular type?

1
2
3
4

Solution:

 

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

print('abcdefcdghcd'.split('cd', 2))

1
2
3

Solution:

What will be the output of the following code?

ch='A'
for i in range(2):
for j in range(0,i+1):
print(ch, end="")
ch=chr(ord(ch)+1)
print()

1
2
3
4

Solution:

What will be the output of the following code?

def fun(): for i in range(3): yield '#'

val = fun() print(next(val)) print(next(val)) print(next(val))

1
2
3
4

Solution:

What will happen when the following code is executed?

import os

os.system('shutdown')

1
2
3
4

Solution:

The code snippet below checks the value of the variable number and prints the corresponding output:

number = 20

if number is:

    10, it prints "10"

    20, it prints "20"

    anything else, it prints "30"

1
2
3
4

Solution:

 

What will be the output of the following Python code?


 a = [5,5,6,7,7,7] b = set(a) 

def test(lst):   

  if lst in b:    

     return

    else:  

       return 0

 for i in  filter(test, a):  

   print(i,end=" ") 

1
2
3
4

Solution: