0% found this document useful (0 votes)
13 views4 pages

Pat 1

The document contains a report of a student's performance in a programming lab at PSG Institute of Technology and Applied Research. It includes the student's personal details, coding assignments, and their respective scores, with some problems marked as correct and others as partially or completely incorrect. The assignments involve creating Python classes for various applications, including a calculator, rectangle, bank account, and score tracking system.

Uploaded by

24d124
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)
13 views4 pages

Pat 1

The document contains a report of a student's performance in a programming lab at PSG Institute of Technology and Applied Research. It includes the student's personal details, coding assignments, and their respective scores, with some problems marked as correct and others as partially or completely incorrect. The assignments involve creating Python classes for various applications, including a calculator, rectangle, bank account, and score tracking system.

Uploaded by

24d124
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
You are on page 1/ 4

4PSG Institute of Technology and Applied Research

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

and he needs to create a simple calculator module as a part of the app.


T2

T2

T2

T2
Users will use this calculator to perform basic math operations.

You should help Angelo design a class named "MathCalculator" to store


two numbers and provide methods for addition, subtraction, multiplication,
and division.

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)

Status : Correct Marks : 10/10


4

24

4
12

12

12
1
4D

4D

4D

4D
T2

T2

T2

T2
2. Problem Statement

Create a Python class Rectangle with private attributes __length and


__width. Include methods to set these attributes, get the area, and get the
perimeter of the rectangle. Allow the class to be initialized with initial
length and width.

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)

Status : Wrong Marks : 0/10


24

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:

deposit (amount): Deposit the specified amount into the account.withdraw


(amount): Withdraw the specified amount from the account.
Answer
class BankAccount():
def deposit(self,acc,bal,am):
x=bal+am
print(f'Deposited:{am:.1f}')
4

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')

Status : Partially correct Marks : 9/10


24

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')

Status : Partially correct Marks : 5.5/10


24

24

4
12

12
D1

D1

4D

4D
4

4
T2

T2

T2

T2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy