Roll No.
: Name of the Student:
NATIONAL INSTITUTE OF TECHNOLOGY, JAMSHEDPUR
Department of Computer Applications
Autumn MID Semester Examination, 2021-22
MCA, 5th Semester
Course Code: CA3503 Course Title: Python Programming
Date: 08/10/2021 Day: Friday
Course Instructor/Instructor in-charge (Name of the Faculty): Dr. Chandrashekhar Azad
Time: 02 Hours Max. Marks: 30
1. Attempt all the questions.
2. Write in your own words and write parts of a question at one place in the answer sheet.
3. Marks of the questions and their part are indicated in the right hand margin.
4. Missing data, if any, may be assumed suitably.
5. Before attempting the question paper, be sure that you have got the correct question
paper.
Question 1. (7+3=10)
a. Shubham is icing a cake. He accomplishes this by combining different cake materials
such as icing sugar, lemon extract, and food color to create three dissimilar types of
decoration: Red, Green, and White. The digits 0 for red, 1 for green, and 2 for white are
used to identify these colors. He divides the cake surface into column stripes (vertical
strips) of width 𝐶1, 𝐶2, . . . , 𝐶n centimeters and row stripes (horizontal strips) of height
𝑅1, 𝑅2, . . . , 𝑅𝑛 centimeters for some positive integer 𝑛 centimeters to get an attractive
pattern. These row and column stripes split the cake surface into 𝑛 × 𝑛 rectangles. The
intersection of row stripe 𝑝 and column strip 𝑞 has color number (𝑝 + 𝑞) 𝑚𝑜𝑑 3 for all
1 ≤ 𝑝, 𝑞 ≤ 𝑛. Shubham needs to know the total surface area in square centimeters to
be colored for each of the three colors in order to create the frosting/icing, and he's asking
for your assistance.
Write a python program to help Shubham.
C1 C2 C3 C4 C5 C6 Cn
R1
R2
R3
R4
R5
R6
Rn
Page 1|3
Input:
on the first line :the integer n
on the second line :the values of C1,C2 . . . , Cn,
on the third line : the values of R1,R2 . . . , Rn
Limit:
The input must fulfills
3 ≤ n ≤ 100000 and
1 ≤ R1, R2. . . , Rn, C1,C2 . . . , Cn ≤ 10000.
Output:
The total area for each color 0, 1, and 2 should be represented by three integers separated
by single spaces.
Example:
6
111111
222222
24 24 24
b. Write case studies for followings:
a. Use of list over tuple
b. Use of list over dictionary
c. Use of list over sets
Question 2. (5+5=10)
a. Write a program in python to demonstrate the order of execution of methods in the
multiple inheritance situation using below given graph for all nodes:
Page 2|3
b. How do we achieve code reusability in python? Write a python code to Explain code
reusability.
Question 3. (5+5=10)
a. Saurabh arranged M*N non negative numbers in the floor for their activity based game,
where M represents number of rows and N represents number of columns. Now Sanchit
will be given a query with two coordinates that represent the top-left and bottom-right
points of a sub-rectangle in the numbers arranged in the floor, respectively. Now you help
by writing a python program to Sanchit, in finding the sum of all the items in the sub-
rectangle.
b. Write any applications of pass by object reference and write the python code for the
same.
*****END*****
Page 3|3