0% found this document useful (0 votes)
2 views3 pages

Python Programming

This document outlines the examination structure for a Python Programming course at PSG College of Technology, including instructions for answering questions and specific programming tasks. Students are required to demonstrate their understanding of Python concepts through various programming assignments, such as creating subscription systems, managing student records, and implementing task management applications. The exam consists of multiple questions, each with subdivisions that focus on different aspects of Python programming.

Uploaded by

abhinav.theone2
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)
2 views3 pages

Python Programming

This document outlines the examination structure for a Python Programming course at PSG College of Technology, including instructions for answering questions and specific programming tasks. Students are required to demonstrate their understanding of Python concepts through various programming assignments, such as creating subscription systems, managing student records, and implementing task management applications. The exam consists of multiple questions, each with subdivisions that focus on different aspects of Python programming.

Uploaded by

abhinav.theone2
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

4933

H
C

C
TE

TE

TE

TE

TE

TE

TE
No of Pages : 3 Course Code : 23I205

Roll No:
G

G
PS

PS

PS

PS

PS

PS

PS
(To be filled in by the candidate)
PSG COLLEGE OF TECHNOLOGY, COIMBATORE - 641 004
H

H
C

C
SEMESTER EXAMINATIONS, DECEMBER 2024
TE

TE

TE

TE

TE

TE

TE
BTech – INFORMATION TECHNOLOGY Semester : 2
G

G
23I205 PYTHON PROGRAMMING
PS

PS

PS

PS

PS

PS

PS
Time : 3 Hours Maximum Marks :100
H

H
INSTRUCTIONS:
C

C
TE

TE

TE

TE

TE

TE

TE
1. Answer ALL questions. Each question carries 20 Marks.
2. Subdivisions (a)(i) and (a)(ii) carries 2 marks each, subdivision (b) carries 6 marks each
G

G
and subdivision (c) carries 10 marks each.
PS

PS

PS

PS

PS

PS

PS
1. a) i) Brief the concept of simultaneous assignment and float, floor division in Python.
H

H
C

C
Provide examples for each and discuss their applications.
TE

TE

TE

TE

TE

TE

TE
ii) Use break and pass statements within a loop in Python to control the flow of
G

G
execution. Provide examples and explain how each statement influences the
PS

PS

PS

PS

PS

PS

PS
iteration process.
b) Design a Python program for a Fitness Studio Subscription System to compute
H

H
subscription fees based on age and plan type. Members under 16, aged 16-40,
C

C
and above 40 have different rates for Standard and Premium plans.
TE

TE

TE

TE

TE

TE

TE
Rates are as follows:
G

G
PS

PS

PS

PS

PS

PS

PS
Standard Plan – Under 16: $20/month, 16-40: $30/month, Above 40: $25/month;
Premium Plan – Under 16: $40/month, 16-40: $50/month, Above 40: $45/month.
H

H
C

C
Include a 15% discount for annual subscriptions. Use the continue statement to
TE

TE

TE

TE

TE

TE

TE
skip invalid inputs and prompt the user for valid data.
G

G
c) Develop a Python program for a video game rating application that determines
PS

PS

PS

PS

PS

PS

whether users can rate games based on their age:


PS
 Continuously prompt the user for their age until they enter a non-numeric
H

H
value to exit.
C

C
TE

TE

TE

TE

TE

TE

TE
 If the age is less than 10, display a message indicating they are not
eligible to rate games.
G

G
PS

PS

PS

PS

PS

PS

PS

 If the age is between 10 and 15 (inclusive), prompt the user to confirm if


they have parental permission.
H


C

If the age is 16 or older, display a message confirming their eligibility to


TE

TE

TE

TE

TE

TE

TE

rate games. Use a while loop to handle user input and exit the loop when
a non-numeric value is entered.
G

G
PS

PS

PS

PS

PS

PS

PS

2. a) i) Discuss the concept of sets in Python, highlighting their characteristics,


uniqueness, and common use cases. Provide examples to illustrate these points.
H

ii) Given the string s = "GEEKSFORGEEKS", print the output for the following:
C

C
TE

TE

TE

TE

TE

TE

TE

print (s[1])
G

print (s[-2])
PS

PS

PS

PS

PS

PS

PS

print(s[3:7])
H

print(s[::-1])
C

C
TE

TE

TE

TE

TE

TE

TE

Page No. : 1
G

G
PS

PS

PS

PS

PS

PS

PS
4933

H
C

C
TE

TE

TE

TE

TE

TE

TE
No of Pages : 3 Course Code : 23I205

b) Develop a Python program for managing student records using a dictionary. The
G

G
PS

PS

PS

PS

PS

PS

PS
program should allow administrators to:
1. Add new students by providing their name, age, and grade.
H

H
C

C
2. View the details of all students currently enrolled.
TE

TE

TE

TE

TE

TE

TE
3. Search for a specific student by name and display their details.
G

G
Use a dictionary to store the student information, where each key is a student's
PS

PS

PS

PS

PS

PS

PS
name, and the value is a sub-dictionary containing the student's age and grade.
c) Develop a Python program for task management using a list. The program
H

H
C

C
should allow the user to:
TE

TE

TE

TE

TE

TE

TE
1. Add new tasks to the list.
G

G
2. View the list of tasks.
PS

PS

PS

PS

PS

PS

PS
3. Remove a completed task from the list.
H

H
4. Handle invalid input when the user attempts to remove a task that does
C

C
not exist.
TE

TE

TE

TE

TE

TE

TE
The program should continuously present a menu with options to add, view,
G

G
remove, or exit the program. It should also validate user input to ensure tasks are
PS

PS

PS

PS

PS

PS

PS
added and removed correctly.
H

H
3. a) i) Predict the correct output for the following Python code snippet:
C

C
TE

TE

TE

TE

TE

TE

TE
numbers = [1, 2, 3, 4]
result = list(map(lambda x: x ** 3 if x % 2 == 0 else x + 1, numbers)) print(result)
G

G
PS

PS

PS

PS

PS

PS

PS
ii) Create a Python package named student_management to streamline the
administration of student data in a school. The package should consist of two
H

H
modules: marks_calculation.py with the function calculate_average_marks() and
C

C
student_info.py with the function print_top_students().
TE

TE

TE

TE

TE

TE

TE
Represent the hierarchical structure of this package with its components.
G

G
PS

PS

PS

PS

PS

PS

b) Describe the purpose of the OS and SYS modules in Python. Discuss how these PS
modules help in interacting with the operating system and handling system-
specific functionalities. Provide five key functions from each module along with
H

H
C

C
examples of how these functions can be used.
TE

TE

TE

TE

TE

TE

TE
c) Develop a Python function called calculate_loyalty_points() that takes the total
G

amount spent by a customer as input and returns the total loyalty points earned
PS

PS

PS

PS

PS

PS

PS

based on the following criteria:


 10 loyalty points for every $100 spent.
H

H
C

 An additional bonus of 200 points if the total amount spent is greater than
TE

TE

TE

TE

TE

TE

TE

$500.

G

If the total amount spent is greater than $1000, provide an extra 500
PS

PS

PS

PS

PS

PS

PS

points as a "VIP bonus."


Ensure that the function returns an integer value representing the total loyalty
H

points earned. The function should handle all conditions without requiring
C

C
TE

TE

TE

TE

TE

TE

TE

additional libraries.
4. a) i) State the purpose of the __init__ method in Python classes. Illustrate its usage
G

with an example to show how it is invoked when a new object is instantiated.


PS

PS

PS

PS

PS

PS

PS

ii) Create a class Animal with a method speak() that prints "Animal sound". Then,
H

create a subclass Dog that inherits from Animal and overrides the speak()
C

C
TE

TE

TE

TE

TE

TE

TE

Page No. : 2
G

G
PS

PS

PS

PS

PS

PS

PS
4933

H
C

C
TE

TE

TE

TE

TE

TE

TE
No of Pages : 3 Course Code : 23I205

method to print "Bark". Use super() in the Dog class to call the speak() method
G

G
PS

PS

PS

PS

PS

PS

PS
from the Animal class.
b) Design a vehicle rental system using two classes: Vehicle and VehicleRental.
H

H
The Vehicle class should store vehicle type, model, and rental price per day. The
C

C
VehicleRental class should:
TE

TE

TE

TE

TE

TE

TE
1. Maintain a list of available vehicles.
G

G
PS

PS

PS

PS

PS

PS

PS
2. Allow adding new vehicles with a method add_vehicle().
3. Calculate rental price based on type and days rented using
H

H
calculate_rental_price().
C

C
TE

TE

TE

TE

TE

TE

TE
c) Explain the concept of inheritance in object-oriented programming. Discuss its
types, including single, multiple, multilevel, hierarchical, and hybrid inheritance.
G

G
Describe how inheritance facilitates flexibility, modularity, and code reuse among
PS

PS

PS

PS

PS

PS

PS
classes. Provide a detailed use case where inheritance is applied and
demonstrate its practical implementation with an example.
H

H
C

C
5. a) i) State the purpose of using NumPy in Python. Provide an example demonstrating
TE

TE

TE

TE

TE

TE

TE
how NumPy helps in performing mathematical operations on arrays efficiently.
G

G
ii) Recall the usage of DataFrames in pandas. List some common operations that
PS

PS

PS

PS

PS

PS

PS
can be performed on DataFrames with an example for creating and accessing a
DataFrame.
H

H
b) Define an exception in Python and list different types of exceptions. Provide
C

C
TE

TE

TE

TE

TE

TE

TE
examples of at least two common exception types and explain their handling
using try and except blocks. Additionally, explain the usage of raise and assert
G

G
statements for handling errors. Illustrate how these statements can be used with
PS

PS

PS

PS

PS

PS

PS
examples.
c) Design a Python program to manage student information by storing their names
H

H
C

C
and grades in a text file. The program should include the following functionalities:
TE

TE

TE

TE

TE

TE

TE
1. Write a function save_students() that creates a file [Link] (if it does not
G

G
exist) and writes student names and grades in the format Name, Grade on
PS

PS

PS

PS

PS

PS

each line. PS
2. Implement a function to read the contents of the file.
H

H
C

3. Create a method to append new student data to the existing file without
C
TE

TE

TE

TE

TE

TE

TE
overwriting [Link] the program handles file operations like reading, writing,
and appending appropriately using modes like 'r', 'w', and 'a'.
G

G
PS

PS

PS

PS

PS

PS

PS

/END/
H

H
C

FD/JU
TE

TE

TE

TE

TE

TE

TE
G

G
PS

PS

PS

PS

PS

PS

PS
H

H
C

C
TE

TE

TE

TE

TE

TE

TE
G

G
PS

PS

PS

PS

PS

PS

PS
H

H
C

C
TE

TE

TE

TE

TE

TE

TE

Page No. : 3
G

G
PS

PS

PS

PS

PS

PS

PS

You might also like