Logo

Python Questions Set 95:

Quiz Mode

print 2*3**2

1
2
3
4

Solution:

What arithmetic operators cannot be used with strings? 

1
2
3
4

Solution:

 How to copy one list to another in python? 

1
2
3
4

Solution:

What is the output of the following Python code?

>>>exec('a=2;b=3;print(a+b)')

1
2
3
4

Solution:

What will be the output of the following Python code?


d = {0: 'a', 1: 'b', 2: 'c'}


for x in d.keys():

    print(d[x])

1
2
3
4

Solution:

 

What will be the output of the following Python code snippet?


 a={1:"A",2:"B",3:"C"}

 print(a.get(1,4)) 

1
2
3
4

Solution:

 

What will be the output of the following Python code?


 def foo(fname, val):  

   print(fname(val))

 foo(max, [1, 2, 3])

 foo(min, [1, 2, 3]) 

1
2
3
4

Solution:

 

What will be the output of the following Python code?

sentence = 'we are humans'
matched = re.match(r'(.*) (.*?) (.*)', sentence)
print(matched.groups())

1
2
3
4

Solution:

 The number of lines drawn in each case, assuming that the turtle module has been imported: 



 

Case 1:
for i in range(0,10):
turtle.forward(100)
turtle.left(90)
Case 2:
for i in range(1,10):
turtle.forward(100)
turtle.left(90)

1
2
3
4

Solution:

What will be the output of the following code?

from calendar import *

print(weekheader(2)+"\n")

print(weekheader(5)+'\n')

1
2
3
4

Solution: