Logo

Python Questions Set 128:

Quiz Mode

 Which of the following is not a type of inheritance?
 

1
2
3
4

Solution:

What is the output of the following Python code?

arr=[1,2,3,4,5]

print(arr[-3:-6:-1])

1
2
3
4

Solution:

What is the output of the given code?


print (None==0)


x=None

y=None

print (x==y)

1
2
3
4

Solution:

What will be the output of the following Python code?

x = 'abcd'

for i in range(len(x)):

    print(i)

1
2
3
4

Solution:

What will be the output of the following code?

 

for i in range(1,6): a = 7 if i < 3: print(i) elif i > 3: print(a)

1
2
3
4

Solution:

What will be the highest number printed by the following code?


print(0)

assert "h"!='w'

print(1)

assert ~2==-3

print(2)

assert 2**3==8

print(3)

assert False

print(2)

1
2
3
4
5

Solution:

 

What will be the output of the following Python code?


 s = 'welcome home'

 m = re.match(r'(.*)(.*?)', s)

 print(m.group()) 

1
2
3
4

Solution:

What is the output of the following code?


from itertools import takewhile

n = [2, 4, 6, 8, 10]

x = list(takewhile(lambda i: i % 2 == 0, n))

print(x)

1
2
3
4

Solution:

  

What will be the output of the following Python code?


 >>> a={4,5,6}

 >>> b={2,8,6}

 >>> a-b 

1
2
3
4

Solution:

 Which of the following is not an advantage of using modules? 

1
2
3
4

Solution: