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

Python Student and Vehicle Management

The document contains Python code examples demonstrating object-oriented programming concepts such as classes, methods, inheritance, and data handling. It includes a student management system with cutoffs, a vehicle class with a car subclass, and examples of calculating percentages using lists and dictionaries. Each section is followed by output showcasing the functionality of the implemented classes and methods.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Python Student and Vehicle Management

The document contains Python code examples demonstrating object-oriented programming concepts such as classes, methods, inheritance, and data handling. It includes a student management system with cutoffs, a vehicle class with a car subclass, and examples of calculating percentages using lists and dictionaries. Each section is followed by output showcasing the functionality of the implemented classes and methods.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Problems :

1)Create A student list with Cutoffs :

class Students:
School_Name="ABCDGHS"
School_Location="Banglore"
def __init__(self,Id,Name,Class_Teacher):
self.Student_ID=Id
self.Student_Name=Name
self.Student_Class_Teacher=Class_Teacher
def Student_Details(self):
print(f"ID:{self.Student_ID}\n"
f"Student_Name:{self.Student_Name}\n"f"Class_Teacher:{self.Student_Class_Teacher}\n")
def Marks_Obtained(self,Phy,Che,Mat):
[Link]=Phy
[Link]=Che
[Link]=Mat
def Marks_Deatails(self):
print(f"Physics:{[Link]}\n"f"Chemistry:{[Link]}\n"f"Maths:{[Link]}\n")
def Average(self):
A=([Link]+[Link]+[Link])/3
print("Average Marks Obtained:",A)
def Cutoff(self):
A=([Link]+[Link]+[Link])/3
if A < 0:
print("Status:Failed")
elif A == 0:
print("Status:Repeat")
else:
print("Status:Passed")
Obj1=Students(101,"Murali","Krishna")
Obj1.Student_Details()
Obj1.Marks_Obtained(0,0,0)
Obj1.Marks_Deatails()
[Link]()
[Link]()

print("--------------------------------------------------------------------------------------")
Obj2=Students(102,"Unni","Abhishek")
Obj2.Student_Details()
Obj2.Marks_Obtained(10,20,40)
Obj2.Marks_Deatails()
[Link]()
[Link]()

Output:

ID:101
Student_Name:Murali

Class_Teacher:Krishna

Physics:0

Chemistry:0

Maths:0

Average Marks Obtained: 0.0

Status:Repeat

--------------------------------------------------------------------------------------

ID:102

Student_Name:Unni

Class_Teacher:Abhishek

Physics:10

Chemistry:20

Maths:40

Average Marks Obtained: 23.333333333333332

Status:Passed

2) Inheritance problem

class Vehicle:
def __init__(self,company,mileage,model):
[Link]=company
[Link]=mileage
[Link]=model
def Startengine(self):
print("Engine is starting")
def Showdetails(self):
print(f"Company:{[Link]}\n"f"Mileage:{[Link]}\n"f"Model:{[Link]}")
def changegear(self):
print("Changing Gear")
class Car(Vehicle):
def opensunroof(self):
print("Opening Sunroof")
def Fuellevel(self,tank1,tank2):
self.tank1=tank1
self.tank2=tank2
def FuellevelIndicator(self):
A=self.tank1+self.tank2
print("Total Fuel level:",A,"Ltr")
def Capacity(self):
A=self.tank1+self.tank2
if A < 40:
print("Status: Very low")
elif A == 0:
print("Status:Need Attention")
else:
print("Status:Fine/Good")
Cobj1=Car("BMW",27,"x2")
[Link]()
[Link]()
[Link]()
[Link]()
[Link](20,40)
[Link]()
[Link]()

Output

Engine is starting

Company:BMW

Mileage:27

Model:x2

Changing Gear

Opening Sunroof

Total Fuel level: 60 Ltr

Status:Fine/Good

Percentage Problem:

class sample:
def __init__(self,ID,Name,Marks:list):
[Link]=ID
[Link]=Name
[Link]=Marks
def Showdetails(self):
print(f"ID:{[Link]}\n"f"Name:{[Link]}\n"f"Marks:{[Link]}")
def Percentage(self):
total=0
for i in [Link]:
total=total+i
per=(total/400)*100
print("Percentage is",per)
Obj1=sample(101,"Murali",[10,20,40,20])
[Link]()
[Link]()

Output

ID:101

Name:Murali

Marks:[10, 20, 40, 20]

Percentage is 22.5

Dictionary Problem :

class sample:
def __init__(self,ID,Name,Marks:dict):
[Link]=ID
[Link]=Name
[Link]=Marks
def getdetails(self):
print(f"ID:{[Link]}\n"f"Name:{[Link]}\n"f"Marks:{[Link]}\n")
def percentage(self):
total=0
for i in [Link]():
total=total+i
per=(total/300)*100
print("Percentage is",per)
Obj1=sample(101,"Murali",{'Phy':23,'Che':21,'Mat':35})
[Link]()
[Link]()

Output

ID:101

Name:Murali

Marks:{'Phy': 23, 'Che': 21, 'Mat': 35}

Percentage is 26.333333333333332

You might also like