21. What is the result of the following operation: '1,2,3,4'.split(',') ?
- ‘1’,’2′,’3′,’4′
- [‘1′,’2′,’3′,’4’]
- (‘1′,’2′,’3′,’4’)
- ‘1234’
23. What is a collection that is unordered, unindexed and does not allow duplicate members?
- Set
- Tuple
- List
24. If x=1 what will produce the below output?
Hi
Mike
if(x==1):
print(‘Hello’)
else:
print(‘Hi’)
print(‘Mike’)
if(x!=1):
print(‘Hello’)
else:
print(‘Hi’)
print(‘Mike’)
- if(x!=1):
print(‘Hi’)else:
print(‘Hello’)
print(‘Mike’)
25. What statement will execute the remaining code no matter the end result?
- If
- For
- While
- Finally
26. What add function would return ‘2’ ?
- def add(x): return(x+x) add(‘1’)
- def add(x): return(x+x) add(1)
- def add(x): return(x+x+x) add(‘1’)
28. What is the output for the below line of code?
A=[8,5,2] for a in A: print(12-a)
8
5
2
4
7
10
888888888888
555555555555
222222222222
Shuffle Q/A 3
30. Consider the class Rectangle, what are the data attributes?
class Rectangle(object):
def __init__(self,width=2,height =3,color='r'):
self.height=height
self.width=width
self.color=color
def drawRectangle(self):
import matplotlib.pyplot as plt
plt.gca().add_patch(plt.Rectangle((0, 0),self.width,
self.height ,fc=self.color))
plt.axis('scaled')
plt.show()
- drawRectangle
- __init__
- self.height, self.width,self.color