Logo

Python Questions Set 20:

Quiz Mode

 What type of data is: a=[(1,1),(2,4),(3,9)]? 

1
2

Solution:

s = "\t\tWelcome\n"
print(s.strip())

1
2
3
4

Solution:

  What is the output when we execute the list(“Abekus”)? 

1
2
3
4

Solution:

 

What will be the output of the following Python code?

>>>example="helloworld"

>>>example[::-1].startswith("d")

1
2

Solution:

What will be the output of the following Python code?

 lst = [1, 2, 3]

 lst[3] 

1
2
3
4

Solution:

Consider a list with elements [3, 4, 5, 20, 3], what is list1 after list.extend([34, 5]) 

1
2
3
4

Solution:

What will be the output of the following Python code?

a = 10
b = 20
c = 3
d = b // a
print(a / 0)
print(d)
e = a * c
print(c)
f = a - b
print(f)

1
2
3
4

Solution:

  

What will be the output of the following Python code?

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

def ttt(m):

   v = m[0][0]

for row in m:

for element in row:

if v < element: v = element

return v

print(ttt(data[0]))

1
2

Solution:

 

What will be the output of the following Python code?

  1. numberGames = {}
  2. numberGames[(1,2,4)] = 8
  3. numberGames[(4,2,1)] = 10
  4. numberGames[(1,2)] = 12
  5. sum = 0
  6. for k in numberGames:
  7.    sum += numberGames[k]
  8. print len(numberGames) + sum

1
2
3
4

Solution:

What will be the output of the following Python code?

veggies = ['carrot', 'broccoli', 'potato', 'asparagus']

veggies.insert(veggies.index('broccoli'), 'celery')

print(veggies)

1
2

Solution: