CST362 Programming in Python, June 2023
CST362 Programming in Python, June 2023
RegNo.:
APJ ABDUL XAIAIVT TECHNOLOGICAL UNIVERSITY
B.Tech Degree 56 (R, S) / 54 (PT) (R, S) Examination June 2023 (2019
PART A
Answer all questions, each carries 3 marks. Marks
Jack says that he will not bother with analysis and design but proceed directly to (3)
coding his programs. Why is that not a good idea?
Write the output of the following python statements : (3)
i) round(I2.57) ii) s//2 iii) int(6.5)
Write the output of following python code : (3)
S : "Computer"
print(S[::2])
print(S[::-l])
print(S[:])
Write a recursive function in python to find GCD of two numbers. (3)
Illustrate the function of following methods in turtle (3)
i) turtle.setheading(0) ii)turtle.forward(50) iii) turtle.left(90)
Describe two fundamental differences between terminal-based user interfaces (3)
and GUIs.
Explain what the str method does and why it is a useful method to include (3)
in a class. - - ;
Compare multiple and multilevel inheritance (3)
Write the output of the following python code: (3)
import numpy as np
arrl : np.arange(6).reshape((3, 2))
arrZ = np.arange(6).reshape((3,2))
Page lof4
o3oocsT36205220L
suitable (3)
What is the difference between loc and
iloc in pandas DataFrame. Give a
l0
examPle.
PART B
Answeronefultquestionfromeochmodule,eachcarriesllmarks.
Module I
(7)
cosine series | - xn2l2l + x^4141''
ll a) write a python program to find the sum of the
Module II
to the string
I'P)rthon rules!"' Use a string (6)
13 a) Assurne that the variable data refers
method to perform the following tasks:
a. Obtain a list of the words in the
string'
Page2of 4
0300csr36205220t
Module III
l5 a) Write a python function to drlw a square using turtle graphics (5)
b) Write a python function to covert an image to black and white using image (9)
processing methods.
OR
16 a) Write a python function to draw an hexagon using turle graphics (5)
' b) Write a python function to shrink an image by a given factor. The function suppose (9)
to builds and returns a new image which is smaller copy of the argument image,
by the factor argument.
Module IV
17 a) Write Python program to create a class called as Complex to model complex (9)
numbers and implement ) and _mul_0 methods to add and multiply
_add_(
two complex numbers. Display the result by overloading the t and * operator.
b) Explain multiple inheritance in Python with a suitable example (5)
OR
l8 a) Write a Python program to create a class called as Rational to model rational (9)
numbers and associated operations. Implement the following methods in the class.
Module V
19 a) Write a code segment that prints the names of all of the items in the current
-(5)
working directory. -;
b) Write a python program to create two numpy arays of random integers between (9)
0 and 20 of shape (3, 3) and perform matrix addition, multiplication and transpose
of the product matrix.
OR
20 a) Write Pyhon program to write the data given below to a CSV file named (4)
student.csv
fields : ['Name', 'Branch', 'Year', 'CGPA']
Page 3of4
--
oilcsT362o/s220r
rows : [ [Nikhil"'csE"'2"'9.0'1,
['Sanchit"'csE,'2"'9.1'1,
, ['Aditya','lT,'2','9.3'1,
['Sagar','IT','l','9.5]I
b) Considerthe above studentcsv file with fields Name, Branch, Year, CGPA. (10)
Write python code using pandas to
l) To find the average CGPA ofthe students
Page 4of 4