Cst362 Programming in Python, May 2023
Cst362 Programming in Python, May 2023
Reg No.:
PART A
Answer oll questions, each carries 3 morks. Marks
What is the output of the following Python code. Justifo your answer. (3)
x: tabcdt
for i in range(len(x)):
print(i)
$rthon.
5 What are the attributes of a turtle object? (3)
6 What are the advantages of GUI based programs over terminal based programs. (3)
7 What is meant by abstraction mechanism in programming? Give one example (3)
abstraction mechanism in Pvthon.
8 Explain the terms accessors and mutators with regard to Python class definition. (3)
9 Write a Python code that checks to sed if a file with the given pathname exists (3)
on the disk, before attempting to open a file for input.
l0 What is Flask in Python? What are its basic components? (3)
PART B
Answer onefull question from eoch module, each carries 14 marks.
Module I
ll a) 2 (7)
Write a Python program to find the roots of a quadratic equation, ax * bx * c:
0 . Consider the cases of both real and imaginary roots.
Page 1of4
0300csr3620s2203
b) Write a Python program to check whether a number is Armstrong number or not. (7)
t,h
An Armstrong number is an n-digit number that is equal to the sum of the n
3334444
Examples:153:l +5 +3 ,1634: I +6 +3 +4
OR
12 a) Write a Python program to display the sum of odd numbers between a (7)
b) (7)
d* * l*r_t_-t+{+{+
'r"'21.';l! '4!
Given the value of x, write a Python program to evaluate the following series upto
n terns:
Module II
13 a) Write a Python program to implement Caesar cipher encryption and decryption (7)
on a string of lowercase letters. Take distance value and the string as input. (Hint:
Caesar cipher encryption strategy replaces each character in the plaintext with the
Page2of 4
.J
0300csT362052203
The interface should have labeled entry fields for these two values. These
components should be arranged in a grid where the labels occupy the first row
and the corresponding fields occupy the second row.
At start-up, the Rupees field should contain 0.0, and the Euro field should contain
0.0. The third row in the window contains two command buffons, labeled R->E
and E->R. When the user presses the first buffon, the program should use the data
in the Rupee field to compute the amount in Euro, which should then be output
to the Euro field. The second button should perform the inverse function.
t b) What are the attributes of a window? How the affribute's value can be changed? (4)
Module IV
17 a) Write a Python program to define a class Rectangle with parameters height, width (7)
and member functions to find area, and perimeter of it.
ft
b) Illustrate how inheritance and polymoiphiin can be implemented in Python. (7)
OR
l8 a) Create a Student class and initialize it with name and roll number. (7)
Make methods to :
Page 3of4
a
0300csT362052203
Module V
lg a) Consider the followintwo-dimensional array name d arr2d (g)
fll,2,3l,
14,5,6f,
[7,9,9])
Write the output of following Python Numpy expressions:
l. an2dl:21
2. an2df:2,l:)
3. an2dll,:21
4. an2df:Z,1:l = 0
b) Write Python program to write the following University topper data of CSE (6)
branch to a CSV file.
OR
| 20 a) Write a Pandas program to read a CSV file named 'Diamond.csv' with fields (4)
carat, cttt, color, clarity, depth, and price and to print the following:
l. Number of rows and columns
2. First five rows
fl
b) Temperature('c) on different dates is+tured in a csv file as (10)
'Weather_data.csv' with the fields date, temperature and humidity.
l.Draw a plot of the weather report with date as the x-axis and temperature as
the y-axis.
- 2. .Draw a scatter plot of the weather report with date as the x-axis and humidity
as the y-axis.
Give appropriate titles and labels in the plot.
{.***
Page 4of 4