1.
What will be the output of the following code:
n = [1, 2, 5, 10, 3, 100, 9, 24]
for e in n:
    if e < 5:
    n.remove(e)
print(n)
2.
You are given two python files, a.py and b.py
File: /somepath/a.py
from b
import multiply_b, print_b

def print_number(number):
    number = multiply_b(number, 4)
print number

def print_b_via_a():
    print_b()

File: /somepath/b.py
 
from a
import print_number

def print_b():
    print_number(3)

def multiply_b(number, multiplier):
    return number * multiplier

The code given below fails with the exception that follows.Why ?
 
    >>>
    import a

ImportError: cannot
import name print_number
3.
The following piece of Python code should produce output 5. What changes should be made to the code to achieve this?
class IntComparer(object):
    ""
"Class that compares two integers."
""

def __init__(self, x, y):
    self.x = x
self.y = y

def greater(self):
    ""
"Returns the greater integer."
""

if self.x < self.y:
    return self.x
else :
    return self.y

def smaller(self):
    ""
"Returns the smaller integer."
""

numbers = [self.x, self.y]
numbers.remove(self.greater())
return numbers[0]

comparer = IntComparer(5, 9)
print(comparer.smaller())# Output should be 5
4.
What is the output of the following Python code:
def func(x, y = 5, z = 10):
    print('x: ', x, 'y: '
        y, 'z: ', z)
1: func(5, 10)
2: func(5, z = 15)
3: func(z = 5, 10)
4: func(x = 5, z = 10)
5.
What is the output of the following Python code:
import re;
sentence = 'eagles are fast'
regex = re.compile('(?Pw+) (?Pw+) (?Pw+)')
matched = re.search(regex, sentence)
print(matched.groups())
6.
What is the output of the following Python code:
myArr = [4, 7, 7, 7, 7, 4]
max = myArr[0]
indexOfMax = 0
for z in range(1, len(myArr)):
    if myArr[z] > max:
    max = myArr[z]
indexOfMax = z
7.
What is the output of the following Python code:
def increment_items(length, increment):
    i = 0
while i < len(length):
    length[i] = length[i] + increment
i = i + 1
values = [1, 2, 3]
print(increment_items(values, 2))
print(values)
8.
What is the output of the following Python code:
veggies = ['cabbage', 'brinjal', 'onion', 'beans']
veggies.insert(veggies.index('brinjal'), 'celery')
print(veggies)
9.
What is the output of the following Python code:
values = [
    [3, 4, 5, 1],
    [33, 6, 1, 2]
]
for row in values:
    row.sort()
print row
10.
What is the output of the following Python code:
my_list = (11, 12, 13, 14)
my_list.append((15, 16, 17))
print len(my_list)