0% found this document useful (0 votes)
91 views4 pages

CST362 Programming in Python, June 2023

This document appears to be an exam paper for a programming in Python course. It contains multiple choice and long answer questions testing knowledge of Python programming concepts and applications. Specific topics covered include functions, strings, files, classes, inheritance, exceptions, NumPy, Pandas and more.

Uploaded by

traderjishnu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views4 pages

CST362 Programming in Python, June 2023

This document appears to be an exam paper for a programming in Python course. It contains multiple choice and long answer questions testing knowledge of Python programming concepts and applications. Specific topics covered include functions, strings, files, classes, inheritance, exceptions, NumPy, Pandas and more.

Uploaded by

traderjishnu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

D 0300csT35205220L

RegNo.:
APJ ABDUL XAIAIVT TECHNOLOGICAL UNIVERSITY
B.Tech Degree 56 (R, S) / 54 (PT) (R, S) Examination June 2023 (2019

Course Code: CST362


Course Name: PROGRAMMING IN PYTHON
Max. Marks: 100 Duration: 3 Hours

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))

arr3 : arrl * arr2[0].resh ape((1, 2))


print(an3)

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

Write a PYthon Program to find X^Y or


pow(X,Y) without using standard (7)
b)
function
OR
following type of pattern for the given
N (7)
12 a) write a python program to generate the

rows where N <= 26.


A
AB
ABCD
ABCDE
to generate prime numbers within a certain
range Q)
b) write a python program

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'

b. Convert the string to uppercase'


c. Locate the position of the string "rules" '

d. Replace the exclamation point with a question mark'


for input and prints the number of four- (8)
b) Write a code segment that opens.efile
letter words in the file
OR
"numbers'txt"' Write a python program
to (10)
14 a) Assume that there is a text file named
the median of list of numbers in the
file without using standard function for
- find
median.
to extract a list of positive numbers
from (4)
b) use higher order python function filter
use a lambda to create the auxiliary
function'
a given list of numbers. You should

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.

Use operator overloading.

l. Reduce0 - to return the simplified fraction form


2. add_0 - to add two ratioanal numbers
3. _lt_Q - to compare two rational numbers (less than operation)
I
b) What is Exception handling? Write a program that opens a file and writes "Hello (5)
Good moring" to it. Handle exceptions that can be generated during VO operations

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

2) To display the details of all students having CGPA > 9

3) To display the details of all CSE students with CGPA > 9


4) To display the details of student with maximum CGPA
5) To display average CGPA of each branch
****

Page 4of 4

You might also like