Logo

Python Questions Set 106:

Quiz Mode

 

What will be the output of the following Python code?

>>>str="hello"

>>>str[:2]

>>>

1
2
3
4

Solution:

What is the output of the code shown below?

def f1(): x = 100 print(x)

x = +1 f1()

1
2
3
4

Solution:

A ____ in Django is basically a collection of objects from our database.

1
2
3
4

Solution:

 

What will be the output of the following Python code?

print('abcd'.partition('cd'))

1
2

Solution:

Find the output of the following code:

a = 10
b = 5
c = 2
d = (a + b) - c * (a // b)
e = d
f = d
print(d)

1
2
3
4

Solution:

Deduce the output of the following code:


from itertools import repeat

a="Hello"

for i in repeat(a,3):

    print(i,end="")

Solution:

 

What will be the output of the following Python code?

numbers = [1, 2, 3, 4]

numbers.append([5,6,7,8])

print(len(numbers))

1
2

Solution:

  What is the output of the code shown below? 

 

set1 = {1, 2, 3} 

set2 = {4, 5, 6} 

print(len(set1 + set2)) 

1
2
3
4

Solution:

Which keyword is used to create a class in Python?

1
2
3
4

Solution:

What is the output of the following code?

import math

[str(round(math.pi)) for i in range(1,6)]

1
2
3
4

Solution: