# Sample Question Paper: Programming and Problem Solving Through Python (M3-R5)

## 1. Each question below gives multiple choices of answers. Choose the most appropriate one.

1.1 The _ provides pictorial representation of given problem.
(a) Algorithm
(b) Flowchart
(c) Pseudocode
(d) All of these

1.2 __ is a procedure or step by step process for solving a problem.
(a) Algorithm
(b) Flowchart
(c) Pseudocode
(d) All of these

1.3 The __ symbol is used at the beginning of a flow chart.
(a) Circle
(b) Rectangle
(c) Diamond
(d) None of these

1.4 What will be the output of the following code:

`Print type(type(int))`

(a) type ‘int’
(b) type ‘typpe’
(c) error
(d) 0

1.5 what is the output of the following code:

`L=[‘a’,’b’,’c’,’d’]Print “”.join[l]`

(a) Error
(b) None
(c) abcd
(d) [‘a’,’b’,’c’,’d’]

1.6 np.eye() is used for creating:
(a) Identity Matrix
(b) Upper triangle Matrix
(c) Lower Triangle Matrix
(d) None of the above

1.7 What is the output of the code print(9//2)
(a) 4.5
(b) 4.0
(c) 4
(d) Error

1.8 What is the output of the following program :

`i = 0 while i< 3: print ii++ print i+1`(a) 0 2 1 3 2 4
(b) 0 1 2 3 4 5
(c) Infinite loop
(d) 0 1 2 3

1.9 Debugging is used to:
(a) Find errors from the program
(b) Check the functionality of the program
(c) Black box testing
(d) All of the above

1.10 The function which reads one line from standards input and returns it as a string (removing the trailing newline)
(a) raw_input
(b) input
(c) eval
(d) accept

## 4) Match the following:- 1×10=10

4.1 The _____ command is used to take input from the keyboard
4.2 The _____ function is used to convert a string value to int.
4.3 The function used to evaluate the value of a string is _
4.4 The _ function takes the parameter filename and the mode during file processing.
4.5 List structure in python where elements are stored in _____ parenthesis.
4.6 The _____ statement lets the program go through the piece of code without performing any action.
4.7 _____ operator repeats a list for the given number of items.
4.8 _____ is a set of functions you want to include in your application.
4.9 The structure having keys and values is called_____.
4.10 The _____ function generates a sequence of numbers from 1 to n.

## PART TWO (Answer any FOUR Questions) Python Questions

Q5. (5+2+5+3 )
a. Make a flow chart to input any number and find its factorial and print.
c. Write a flowchart that finds the sum of series: s=1+x/1!+2x/2!+3x/3!+ upto n terms
d. What is a NumPy array. How they are different from lists?

Q6. (5+5+5)
a. Write a recursive function to find the sum of digits of a number.
b. Write a program that takes a sentence as input from the user and returns the frequency of each letter .Use a variable of dictionary type to maintain the count.
c. Program to check whether a string is palindrome or not.

Q7. (5+10)
a. Take an array of 2 rows and three columns, populate it and find the transpose.
b. Explain the following with example:

1. LEGB rule
2. Seek() function
3. Tell()
4. String slicing
5. List comprehension

Q8. ( 6+6+3)
a. Write a function that takes data to be stored in the file f1 as interactive input till user
responds with nothing as input. Each character taken as input rom the user must be
capitalized and stored in file f1.
b. Write a function that reads the contents of the file myfile.txt and counts the number of alphabets, lowercase letters, uppercase letters, digits and no of words.
c. Take two NumPy arrays having two dimensions. Concatenate the arrays on axis 1.

Q9. (5+5+5)
a. Write a recursive function to count the sum of digits of a number
b. Write a program that takes m as an input parameter and creates a list of m lists such that xth list contains first three multiples of x.
c. Store the monthly earnings of a year of a store splitting up the earnings by quarter into a list of lists. Retrieve the earnings of every month in a loop and display the quarter with maximum earnings.

Buy O Level Books (Updated 5th revised)