You are on page 1of 4

SECTION A

I. FILL IN THE BLANKS. 1*20=20

1. ..................... is the python operator responsible for declaring variables.

2. An ..................... is a symbol used to perform an action on some values.

3. The modules in python have the .................extension.

4. In python, the non-zero value is treated as.............. and zero values is treated as.......................

5. The function which is written by the programmer as per his/her requirements is known
as...................

6. The .........................of a variable is the area of the program where it may be referred.

7. The first line of a function definition is called...............

8. Function that do not explicitly return a value return the special object ................

9. A python ............. is a directory of python modules.

10. By default, python names the segment with ...................

11. The ................... module lets you send and receive http request and their results .

12.A data structure has well defined ..............and..........

13.A........................ is a mutable sequence of data elements indexd by their position.

14. ....................... means accessing or processing each element of any data structure.

15. Consider the following code:

Push(5),push(8),pop(),push(2),push(5),pop(),pop(),pop(),push(1),pop()

The output of the above snippet is..........................

15.In a stack, if a user tries to remove an element from stack is called....................

16. Pushing an element into a stack already having 10 elements and a stack of size 10,then the stack
becomes.....................

17. The help <module> statement displays ...........from a module.

18. In ....................... the given argument types can be skipped from a function call.

19. What will be the output for: print(“100+200”)

20. Predict the output for


D={0: ‘a’,1: ‘b’,2: ‘c’}
for i in x:
print(i)
II. Answer all 10*2=20
21. State some distinguishable features of python.
22. Predict the output for :
X=50
def func(X):
X=2
func(X)
Print(‘x is now’, X)
23. Find the error:
def minus(total, decrement)
output=total-decrement
return output
24.From the program code ,identify the parts mentioned below:
def processnumber(x):
x=72
return x+3
y=54
res=processnumber(y)
25. Find the output of the following:
word= ‘green vegetables’
print(word.find(‘g’,2))
print(word.find(‘veg’,2))
print(word.find(‘tab’,4,15))
26. Suppose L=[“abc”,[6,7,8],3, “mouse”]
Consider the above list and answer the following:
a. L[3:] b. L[::2] c. L[1:2] d. L[1][1]
27. Define module and package.
28.Consider the following stack of characters implemented as an array of 4 elements
STACK=[“A”, “J”, “P”, “N”]
Describe the stack as the following operations takes place.
a.STACK.pop() B.STACK.append(K) c.STACK.append(S) d.STACK .pop()
e.STACK.append(G)
29.Define data structure. Classify it’s types.
30.Explain the working principle of data structures stack and queue.

29. Define stack?What basic operations can be performed on them?Enlist some applications of
stacks.
30. Explain data item and data type.

III. ANSWER ALL 3*5=15


31. Evaluate the following arithmetic expression which is in postfix notation .Show the contents of
the stack during the execution of the algorithm using the following:30,5,2,**12,6,/,+,-.
32. Evaluate the following postfix notation of expression .Show status of stack after each operation.
False,True,Not,Or,True,False,And,Or
33.Here is the code for pop method in stack to print a string in reverse order.But thre is some
missing word.Answer the questions that follow to execute the code successfully.
def popstack(stack)___#Line 1
if isempty(stack): #Line 2
_______ #Line 3
__________:Line 4
Top=len(stack)___#Line 5
for a in range(top,-1,-1):
print stack__#Line 7
return
Q.1. Which symbol is used to terminate the function popstack()?
a.; b.: , d.!
Q.2. Fill the blank in line 3
Q.3. Which variable or keyword will be best suited in fill in the blank in Line 4.
Q.4. Fill the blank in Line 5
Q.5. Which value will be used in Line 7
IV.ANSER ALL 4*5=20
34.Consider the following code and answer the questions:
Book={1: ‘Thriller’,2: ‘Mystery’, 3: ‘Crime’,4: ‘Children stories’}
Library={‘5’, ‘Madras Diaries’, ‘6’, ‘Malgudi Days’}
Q.1. Ramesh needs to change the title in the dictionary book from ‘Crime’ to ‘Crime Thriller’. He
has written the following command:
a.Book[2]= ‘Crime Thriller’
b. Book[3]= ‘Crime Thriller’
c. Book[2]=( ‘Crime Thriller’)
d. Book[3]=(‘Crime Thriller’)

Q.2. The command to merge the dictionary Book with Library the command would be:
a. d=Book+Library
b. print(Book+Library)
c. Book.update(Library)
d. Library.update(Book)

Q.3. What will be the output of the following code:print(list(Library))


a.[‘5’,Madras diaries’,’6’,’Malgudi Days’]
b.[‘Madras diaries’, ‘Malgudi Days’]
c.[‘5’, ‘6’]
Q.4. In order to check whether the key 2 is present in the dictionary Book, Ramesh uses the
following command:
2 in Book
He gets the answer ‘True’. Now to check whether the name ‘Madras Diaries’ exists in the
dictionary Library, he uses the following command:
‘Madras Diaries’ in the library But he gets the answer as ‘False’. Select the reason for this:
a. We cannot use the in operator with values. It can be used with the keys only.
b. We must use the function Library, values() along with the in operator.
c. We can use the Library.items() function instead of the in operator
d. Both b and c are correct.

Q.5. With reference to the above declared dictionaries, predict the output of the following code
fragments
35. Predict the output
a. b=[[9,6],[4,5],[7,7]] b. b=[[9,6],[4,5],[7,7]]
x=b[:2] x=b[:2]
x.append(10) x[1].append(10)
print(x) print(x)
36. Consider the following similar codes ,carefully go through these and predict the output
i. x='ball'
y='boy'
c=[x+y for x in 'ball' for y in 'boy']
print(c)

ii. text=['h','a','r','d','w','o','r','k']
print(text)
vowels="aeiou"
newtext=[x.upper() for x in text if x not in vowels]
print(newtext)
37. Define Binary search . Illustrate the process of binary search in array with an example. write
the program to implement the same.

You might also like