# Jul 2021 M3 R5 Programing and Problem Solving through Python

This paper is NIELIT  Orginal O Level Previous Year paper July 2021. For more Paper visits the NIELIT website

1. Each question below gives a multiple choice answer. Choose the most appropriate one and enter in the “OMR” answer sheet supplied with the question paper, following instructions therein.(1 x10)

1.1)Find the output of the following python programs.

a=” Meetmeafterparty”

b=13

print a+b

(A)29

(B)14

(C)error in code

(D)15

1.2)Find the output of the following Python programs

Class Acc:

def _init_(self,id):

Self.id=id

Id=555

acc=Acc(111)

print acc. id

(A)111

(B)555

(C)666

(D)error in code

1.3)Which of the following is an invalid variable?

(A)my_string_1

(B)foo

(C)_

(D)1st_string

1.4)Find the output of the following Python programs.

x=[‘ab’, ‘cd’]

for i in x:

i.upper()

print(x)

(A)ab

(B)cd

(C)[‘ab’, ‘cd’]

(D)[‘cd’, ‘ab’]

1.5)What is the output of the following program?

a =2

b = ‘3.77’

c =-8

str1= ‘{0.4f} {0:3d} {2} {1}’.format (a,b,c) print(str1)

(A)2.0000 2-83.77

(B)23.77 -83.77

(C)2.000 3-83.77

(D)2.000 2 8 3.77

1.6)Find out the output of the following Python programs:

def gfg (x,l=[]):

for i in range (x):

l.append(i*i)

print(l)

gfg(2)

(A)[3,2,1,0,1,4]

(B)[0,1]

(C)[0,1,0,1,4]

(D)error in code

1.7)Suppose t =(1,2,4,3), which of the following is incorrect?

(A)print (t)

(B)t=45

(C)print(max(t))

(D)print(Len(t))

1.8)What will be the output of the following Python code?

>>>t1=(1,2,4,3)

>>>t2=(1,2,3,4)

>>>t1<t2

(A)True

(B)False

(C)Error

(D)(1,2,4,3)

1.9) Which of the following statements is false about recursion?

(A)Every recursion function must have a base case

(B)Infinite recursive can occur if the base case isn’t properly mentioned

(C)A recursive function makes the code easier to understand

(D)Every recursive function must have a return value

1.10)What will be the output of the following Python code?

import functools

l=[1,2,3,4,5]

m =functools.reduce (lambda x,y:xif x>y else y,l)

else y,l)

print(m)

a)Error

c)1

d)5

2) Each statement below is either TRUE or FALSE. Choose the most appropriate one and enter your choice in the “OMR” answer sheet supplied with the question paper, following instructions therein. (1 X 10)

2.1) Python is a high-level, interpreted, interactive, and object-oriented scripting language. It is designed to be highly unreadable.

2.2)Python is derived from many other languages, including ABC, Modula-3, C, C++, Algo1-68, Small Talk, and Unix shell, and other scripting languages.

2.3) In Python assignment of more than one behavior to a particular function and the operation performed varies by the types of objects or arguments involved are known as operator overloading.

2.4) To access values in a tuple, use the square brackets for slicing along with the index or indices to obtain the value available at that index.

2.5) The Python standard for database interfaces is the Python SB-API. Most Python database interfaces adhere to this standard.

2.6)If a connection is established with the data source then a Connection Object is returned and saved into DB. for further use, otherwise, DB. is set to None.

2.7)The tell() method tells you the current position within the file.

2.8)Removing individual tuple elements is possible.

2.9)The first method _ init _ () is a special method, which is called class constructor or initialization method that Python calls when you create a new instance of this class.

2.10)When a Python script raises an exception, it must either handle the exception immediately otherwise it terminates and quits.

3.) Match words and phrases in column X with the closest related meaning /word(s)/phrase(s) in column Y. Enter your selection in the “OMR” answer sheet supplied with the question paper, following instructions therein. (1 X 10)

 Column X Column Y 3.1) Error does not fall into any category A.)time. Altzone 3.2)The arguments have invalid values specified B.)tuple(seq) 3.3)Opens a file for both reading and writing in  binary format C.)tell() 3.4)Function blocks begin with the keyword D.) Value Error 3.5)Negative count from the right E.)rb+ 3.6)Method displays the current working directory F.)Runtime Error 3.7)The offset of the local DST time zone G.)L[-2] 3.8)Converts a list into a tuple H.)def 3.9)Shows current position within the file I.)del 3.10)Explicitly remove an entire tuple J.)getcwd() K.)Syntax Error L.)Rb- M.)L[-1]

4.) Each statement below has a blank space to fit one of the word(s) or phrase(s) in the list below. Enter your choice in the “OMR” answer sheet attached to the question paper, following instructions therein.  (1X10)

 (A)time.time() (B)24 (C)parentheses (D)reference (E)more (F)local variables (G)TRUE (H)Guido van Rossum (I)function (J)objects (k) less (L)FAlSE (M)Tim Berner

4.1) The output of following Python program is __________.

r =lambda q:q*2

s =lambda q:q*3

x =2

x =r(x)

x =s(x)

x =r(x)

print x

4.2) Let consider the following Python code

a =True

b =False

c =False

if a or b and c:

print “TRUE”

else:

print “FALSE”

the output of this code is ________.

4.3) Recursive functions usually take ________ memory space than non-recursive function.

4.4) Python programming language was created by ________.

4.5) Python supports Object-Oriented style or technique of programming that encapsulates code within_______.

4.6) _________ returns the current time instant, a floating-point number of seconds since the epoch.

4.7) All parameters (arguments) in the Python language are passed by________.

4.8) The _________ can be accessed only inside the function in which they are declared, whereas global variables can be accessed throughout the program body by all function.

4.9) The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use __________ whereas lists use square brackets.

4.10) Python converts numbers internally in an expression containing mixed types to a Common type for evaluation. But sometimes, coerce a number explicitly from one type to another to satisfy the requirements of ________parameter.

5.)           (a) Write the basic steps required by the interpreter to execute a Python program.

(b)Predict and explain the output of following program

r=lambda q:q*2

s=lambda q:q*3

x=2

x=r(x)

x=s(x)

x=r(x)

print(x)

(c)How memory is managed in Python? Give the tools name that helps to find bugs or perform the static analysis?  (5+5+5)

6.)           (a)Write a Python program to compute the factorial of a given number using recursion.

(b)Define mutable and immutable data types. Explain the concept of Linear and Binary search with Python program.

(c)Write code snippets in Python to perform Accessing Elements of a Tuple.  (3+8+4)

7.)           (a) How will you create a Package and import it ? Explain it with an example program.

(b) Explain the following:

(i) List Slicing

(ii) List accessing methods (7+8)

8.)           a) Illustrate the LEGB rules and their significance with help of a suitable diagram.

1. b) Explain about python slice. Write the syntax of the slice and discuss it. (7+8)

9.)           (a) Define NumPy ? How to create NumPy array?

(b) Explain the flowchart and symbols used in the flowchart. Write the algorithm, pseudo-code, and draw the flowchart for towers of Hanoi. (6+9)

### Jul 2021 M3 R5 Python Solution (Part 1)

 1.1 C 1.2 D 1.3 D 1.4 C 1.5 A 1.6  B 1.7 B OR D 1.8  B 1.9 B 1.10 D 2.1 F 2.2 T 2.3 F 2.4 T 2.5 T 2.6 T 2.7 T 2.8 F 2.9 T 2.10 T 3.1 F 3.2 D 3.3 E 3.4 H 3.5 G 3.6 J 3.7 A 3.8 B 3.9 C 3.10 I 4.1 B 4.2  L 4.3 E 4.4 H 4.5 J 4.6 A 4.7 D 4.8 F 4.9 C 4.10 I

### Jul 2021 M3 R5 Python Solution (Part 1)2

Complete Part1 and Part 2 Solution Only   Rs 20 Rs 15

error: Content is protected !!