Logo

Python Questions Set 127:

Quiz Mode

fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana']
>>> fruits.count('apple')

Solution:

Which of the following data types in Python are immutable?

1
2
3
4
5

Solution:

What is the output of the following code?


print("x" is "x", [] is [])

1
2
3
4

Solution:

The <div> element that wraps a new empty block is called which of the following?

1
2
3
4

Solution:

 

 

What will be the output of the following Python code?


 x = [12, 34] 

print(len(''.join(list(map(int, x))))) 

1
2
3
4

Solution:

 

What is the average value of the following Python code snippet?

>>>grade1 = 80

>>>grade2 = 90

>>>average = (grade1 + grade2) / 2

1
2
3
4

Solution:

Identify the type of errors in the following Python code:

print("Good Morning")
print("Good night")

1
2
3
4

Solution:

Deduce the output of the following code:


b=0

c=0

for i in range(1, 6):

    if i == 3:

        break

    b+=i

for i in range(1, 6):

    if i == 3:

        continue

    c+=i

print(b+c)

Solution:

What will be the output of the following Python code?

def arithmetic(a, b, c): e = a * b * c d = e - 10 f = d // 2 return f a = arithmetic(2, 3, 4) print(a)

1
2
3
4

Solution:

What is the output of the following code?

class Test:
   def __init__(self):
       self.x = 0
class Derived_Test(Test):
   def __init__(self):
       self.y = 1
def main():
   b = Derived_Test()
   print(b.x,b.y)
main()

1
2
3
4

Solution: