Q7
Q7
Q7
Q7)A- ) Write a python Program to display welcome to “JSPM University” by using classes and
objects?
print("RUTUJA KANE")
class University:
def display_message(self):
university_obj = University()
university_obj.display_message()
OUTPUT:-
NAME:RUTUJA KANE SUBJECT: PPL ROLLON:48 DIV:C(AIML)
B) Write a python Program to call data member and function using classes and objects?
print("RUTUJA KANE")
# Define a class
class Student:
# Data members
self.name = name
self.age = age
def display_details(self):
student1 = Student()
student1.display_details()
NAME:RUTUJA KANE SUBJECT: PPL ROLLON:48 DIV:C(AIML)
OUTPUT:-
NAME:RUTUJA KANE SUBJECT: PPL ROLLON:48 DIV:C(AIML)
C) Write a program to find sum of two numbers using class and methods?
print("RUTUJA KANE")
class Calculator:
calc = Calculator()
OUTPUT:-
NAME:RUTUJA KANE SUBJECT: PPL ROLLON:48 DIV:C(AIML)
D) Write a program to read 3 subject marks and display pass or failed using class and object.?
print("RUTUJA KANE")
class Student:
self.name = name
self.marks = []
def input_marks(self):
for i in range(3):
self.marks.append(mark)
def check_result(self):
if len(self.marks) == 3:
average = sum(self.marks) / 3
print(f"\nStudent: {self.name}")
print("Result: Passed")
else:
print("Result: Failed")
else:
# Driver code
if __name__ == "__main__":
student = Student(student_name)
NAME:RUTUJA KANE SUBJECT: PPL ROLLON:48 DIV:C(AIML)
OUTPUT:-