Nothing Special   »   [go: up one dir, main page]

Unit Test 2 - PP - WS - 2021-QP1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Reg.No.

VTUDEC03
Vel Tech Rangarajan Dr. Sagunthala R&D Institute of Science and
Technology (Deemed to be University Estd. u/s 3 of UGC Act, 1956)
School of Computing
Department of Computer Science and Engineering
VTU R 15

UNIT TEST – II
B.Tech. - CSE

Course Category : Program Elective Duration : 50 Minutes


Course Code/ Title :1152CS119/ Python Programming Max. Marks : 10
Semester : Winter / 2020 – 2021 Date of Test :22.5.2021

Achievable Course Outcomes

CO3: Describe Object oriented concepts with python K2 Level

Course
Answer all the Questions. Marks Level
Outcome
1. a Predict the output of following Python programs? 1 CO3 K2
class X(object):
def __init__(self, a):
self.num = a
def doubleup(self):
self.num *= 2
class Y(X):
def __init__(self, a):
X.__init__(self, a)
def tripleup(self):
self.num *= 3
obj = Y(4)
print(obj.num)
obj.doubleup()
print(obj.num)
obj.tripleup()
print(obj.num)
b Give a suitable example using Python code to illustrate single level 2 CO3 K2
inheritance considering COUNTRY to be BASE class and STATE to
be derived class.

c How do you implement abstract methods in Python? Give an example 2 CO3 K2


for the same.
2. a Write a Python program using classes and objects to simulate a result 3 CO3 K2
preparation system for 20 students. The data available for each student
includes: Name, Rollno, and Marks in 3 subjects. The percentage
marks and grade are to be calculated from the following information:

Also demonstrate constructor overloading.


b 2 CO3 K2
Design an arithmetic calculator with different arithmetic operations.
Your calculator has to perform the following operations - addition,
subtraction, multiplication, division. Display a menu of the above
operations and let the user choose from the menu. Based on user
choice, perform the operation and also predict what kind of error can
occur for the operation. If the user enters any erroneous input, handle
the error for different input formats. Demonstrate the exception
handling.

K1-Remember K2-Understand K3-Apply K4-Analyze K5-Evaluate K6-Create

You might also like