Pat 1
Pat 1
4
12
12
12
12
4D
4D
4D
4D
T2
T2
T2
T2
Name: Krishna J Scan to verify results
Email: 24d124@psgitech.ac.in
Roll no: T24D124
Phone: 7200019640
Branch: PSG iTech
Department: AI&DS
Batch: 2028
Degree: B.Tech AI&DS
4
24
4
12
12
12
2028_II_AI&DS_Datastructure Design Lab
1
4D
4D
4D
4D
T2
T2
T2
T2
PSGiTech_2027_DSD_Python_Week 1_Skill Builder
Attempt : 1
Total Mark : 40
Marks Obtained : 24.5
Section 1 : Coding
1. Problem Statement
4
24
24
4
12
12
Angelo is developing a mobile application for a math learning platform,
D1
1
4D
4D
4D
4
T2
T2
T2
Users will use this calculator to perform basic math operations.
Answer
# You are using Python
class MathCalculator():
def add(self,x,y):
24
24
4
12
12
D1
D1
print('Addition:',x+y)
4D
4D
4
def sub(self,x,y):
T2
T2
T2
T2
print('Subtraction:',x-y)
4
4
def mul(self,x,y):
12
12
12
12
4D
4D
4D
4D
print('Multiplication:',x*y)
T2
T2
T2
T2
def div(self,x,y):
print(f'Division: {(x/y):.2f}')
m=MathCalculator()
a=int(input())
b=int(input())
m.add(a,b)
m.sub(a,b)
m.mul(a,b)
m.div(a,b)
24
4
12
12
12
1
4D
4D
4D
4D
T2
T2
T2
T2
2. Problem Statement
Answer
# You are using Python
class Rectangle:
4
24
24
4
def area(self,a,b):
12
12
D1
1
4D
4D
4D
print(f'Area of the rectangle: {(a*b):.2f}')
4
T2
T2
T2
T2
def peri(self,a,b):
print(f'Perimeter of the rectangle: {(2*(a+b)):.2f}')
__length=float(input())
__width=float(input())
r=Rectangle()
r.area(__length,__width)
r.peri(__length,__width)
24
3. Problem Statement
12
12
D1
D1
4D
4D
4
4
T2
T2
T2
T2
A client has approached you to create a simple banking application that
4
4
12
12
12
12
allows users to deposit and withdraw money from their bank account. The
4D
4D
4D
4D
T2
T2
T2
T2
client wants a program that utilizes the "BankAccount" class with the
following methods:
24
4
12
12
12
print(f'New balance:{x:.1f}')
1
4D
4D
4D
4D
def withdraw(self,acc,bal,am):
T2
T2
T2
T2
x=bal-am
print(f'Withdrew:{am:.1f}')
print(f'New balance:{x:.1f}')
B=BankAccount()
a=input()
b=float(input())
c=input()
if c=='1':
am=int(input())
if am==0:
4
24
24
4
12
12
print('Invalid deposit amount')
D1
1
4D
4D
4D
else:
4
T2
T2
T2
T2
B.deposit(a,b,am)
elif c=='2':
am=int(input())
if am==0:
print('Invalid withdrawal amount')
else:
B.withdraw(a,b,am)
else:
print('Invalid choice')
24
4
12
12
D1
D1
4D
4D
4
4
T2
T2
T2
T2
4. Problem Statement
4
4
12
12
12
12
4D
4D
4D
4D
Ragul is an avid gamer who wants to keep track of his gaming scores. He
T2
T2
T2
T2
is looking for a simple score tracking application, and he decided to create
a program and implement a class called "Score" to manage a player's
score. Ragul's application allows the player to add points to their score,
reset the score to zero, and view the current score.
Answer
# You are using Python
class score():
def add(self,n,s,i=0):
print(f'{n}: {i} points')
4
24
4
12
12
12
print(f'{n}: {i+s} points')
1
4D
4D
4D
4D
def zeroo(self,n,i=0):
T2
T2
T2
T2
print(f'{n}: {0} points')
s=score()
n=input()
a=int(input())
while True:
b=input()
if b=='2':
s.zeroo(n,a)
elif b=='1':
x=int(input())
s.add(n,x,a)
4
24
24
4
12
12
elif b=='3':
D1
1
4D
4D
4D
break
4
T2
T2
T2
T2
else:
print(f'{n}: {a} points')
print('Invalid choice')
24
4
12
12
D1
D1
4D
4D
4
4
T2
T2
T2
T2