Logo

Python Questions Set 167:

Quiz Mode

 Which of the following is an invalid variable? 


1
2
3
4

Solution:

>>> my_list = [0, 2, 2]

>>> a = all(my_list)

>>> print(a)

1
2
3
4

Solution:

Suppose list1 is [44, 33, 22, 14, 20], what is the value of list1[-1]?

1
2
3
4

Solution:

snow = 26

cat = True

print "there are %s letters in the alphabet- %s" %('snow', cat)     

Solution:

The association between a URL and the function that handles it is called:

1
2
3
4

Solution:

 

What will be the output of the following Python code?


 >>> a={5,4}

 >>> b={1,2,4,5} 

>>> a<b 

1
2
3
4

Solution:

What is the correct sequence of the parameters in the range() function?

1
2
3
4

Solution:

m, n = map(int, input().split())

def function(m, n):

return m**n

m = function(m, n)**2

print(function(m, n))


If the entered string is 1 2, find the output of the above code.

1
2
3
4

Solution:

Find the output of the following code:


>>> string = " Hello World "

>>> x = string.lstrip()

>>> y = string.strip()

>>> x, y

1
2
3
4
5

Solution:

Guess the output of the following code:


import re

text="""

abcdefghijklmnopqrstuvwxyz

ABCDEFGH"""


pattern=re.compile(r'abc')

matches=pattern.finditer(text)

for match in matches:

    print(match)

1
2
3
4

Solution: