Logo

Python Questions Set 168:

Quiz Mode

import re

1
2
3
4

Solution:

How many lines does the following code prints.


x="Hello World."

for i in x:

    print(i)

Solution:

x = ['ab', 'cd']

print(list(map(len, x)))

1
2
3
4

Solution:

 

What will be the output of the following Python code?

lst=[[1,2],[3,4]]
print(sum(lst,[]))

1
2

Solution:

What will be the output of the following code?

if 2 & 4:

     print("Easy")

else:

     print("Peasy")

1
2
3
4

Solution:

 

What is the output of the following program?

def Foo(x):
 if (x==1):
   return 1
 else:
   return x+Foo(x-1)

print(Foo(4))

1
2
3
4

Solution:

Write a list comprehension for number and its cube for:

l=[1, 2, 3, 4, 5, 6, 7, 8, 9]

1
2
3
4

Solution:

 

What will be the output of the following Python code?

def f(i, values = []):

   values.append(i)

return values

f(1)

f(2)

v = f(3)

print(v)

1
2

Solution:

What is the relationship between the variables lst and num in the following code?

lst = [1, 2, 3, 4]

num = lst

1
2
3
4

Solution:

Find the output of the following code:

def minimum(x, y, z): def findmin(x, y, z): x = min(x, y, z) return x return findmin z = minimum(11, 15, 8) print(z(20, 35, 25))

1
2
3
4

Solution: