cst362 Programming in Python June 2022
cst362 Programming in Python June 2022
D 0300csT362052202
Write a Python program to count number of even numbers and odd numbers in (3)
8 Write a Pyhon class which has two methods get_distance and print distance. (3)
I
get distance accept a distance in kilomefres from the user and print_distance
print the distance in meter.
9 How do you assign a ranclom number to a variable in Pyhon? (3)
PART F-
Answer onefull questionfrom each module, each carries 14 mnrks.
Module I
11 a) Write a python program to generate the following type of pattern for the given N (6)
rows.
.1
t2
t23
1234.
Page 1of3
o300csT352052202
b) Mention the different typis of loop and control statements allowed in Python (8)
and explain each type with suitable examples
OR
12 a) Write the python program to print all prime numbers less than 1000. (7)
b) Write a Python program to find distance between two points (xl,yl) and (x2,y2). (7)
Module II
13 a) Write a Python program to count how many times each character appears in a (7)
given string and store the count in a dictionary with key as the character.
b) Create a function min_max0 that takes n numbers as list argument and return the (7)
smallest and largest numbers.
,f OR
14 a) Write a Python program to read n integers into a list and separate the positive (7)
and negative numbers into two different lists.
b) Create a dictionary of names and birthdays. Write a Python program that asks (7)
the user to enter a name, and the program display the birthday of that person.
Module III
15 a) How to draw a star shape using turtle in Python. (5)
b) Explain basic image processing with inbuilt functions in $rthon. (9)
OR
16 a) Write Python GUI program to take the birth date and output the age when a (7)
r button is pressed.
b) How do you display an image in Python GUI?. (7)
1 .--: Module IV
l7 a) Demonstrate how polymorphism can be implemented using function '(7)
* overloading with suitable example. _j I
b) Illustrate with a real life example how multi-level inheritance is implemented in (7)
Python.
OR
18 a) Create an Abstract Base Class called Shape that include abstract methods areaQ (7)
- unO circumferenceQ. Then derive two classes Circle and Rectangle from
the Shape class and implement the area0 and circumference$ methods . Write a
Python program to implement above concept.
b) How elceptionsare handled in Python?. Illustrate with the help of an example. (7)
Page2of3
GFOCSlil62AS2202
"
Modalc V
19 a) Explain how the matrix multiplitations are done using numpy arrays. (7)
b) How to plot two or more lines on a same plot with suitable legends, labels and i iZl
title.
OR
20 a) Consider a CSV file 'employee.csv' with the following (8)
' columnsftarne, gendgr, start_date ,salary, team).
Write commands to do the following using panda library.
l. print first 7 records fiom employees file
, 2. print all employee names in alphabetical order
3. find the name ofthe employee with highest salary
.rl
4. list the names of male employees
5. to which all teams employees belong
b) Write Pyhon program to write the data given below to a CSV file (6)
Page 3of3