Learn Computer Programming Free from our source codes in my website.
Sponsored Link Please Support
https://www.techseries.dev/a/27966/qWm8FwLb
https://www.techseries.dev/a/19181/qWm8FwLb
My Personal Website is http://www.jakerpomperada.com
Email me at jakerpomperada@gmail.com and jakerpomperada@yahoo.com
Sunday, September 29, 2024
Saturday, September 28, 2024
Friday, September 27, 2024
Monday, September 23, 2024
Friday, September 20, 2024
Thursday, September 19, 2024
Wednesday, September 18, 2024
Tuesday, September 17, 2024
Sunday, September 15, 2024
Saturday, September 14, 2024
Friday, September 13, 2024
Wednesday, September 11, 2024
Tuesday, September 10, 2024
Monday, September 9, 2024
Sunday, September 8, 2024
Student Records Using Encapsulation in Python
Student Records Using Encapsulation in Python
ScreenshotProgram Listing
class Student:
def __init__(self, student_name, student_age, student_grade):
self.name = student_name
self.age = student_age
self.grade = student_grade
def get_name(self):
return self.name
def get_age(self):
return self.age
def get_grade(self):
return self.grade
def set_name(self, student_name):
self.name = student_name
def set_age(self, student_age):
self.age = student_age
def set_grade(self, student_grade):
self.grade = student_grade
if __name__ == "__main__":
student = Student("Julianna Rae Pomperada", 16, 92)
print("\n\tStudent Records Using Encapsulation in Python")
print("\n\tDisplay Student Record\n")
print("\tStudent Name: " + student.get_name())
print("\tStudent Age: " + str(student.get_age()) + " years")
print("\tStudent Grade: " + str(student.get_grade()))
student.set_name("Jacob Samuel Pomperada")
student.set_age(18)
student.set_grade(88)
print("\n\tUpdated Student Record\n")
print("\tStudent Name: " + student.get_name())
print("\tStudent Age: " + str(student.get_age()) + " years old.")
print("\tStudent Grade: " + str(student.get_grade()))
print("\n\tEnd of Program. Thank you for using this program.")
self.name = student_name
self.age = student_age
self.grade = student_grade
def get_name(self):
return self.name
def get_age(self):
return self.age
def get_grade(self):
return self.grade
def set_name(self, student_name):
self.name = student_name
def set_age(self, student_age):
self.age = student_age
def set_grade(self, student_grade):
self.grade = student_grade
if __name__ == "__main__":
student = Student("Julianna Rae Pomperada", 16, 92)
print("\n\tStudent Records Using Encapsulation in Python")
print("\n\tDisplay Student Record\n")
print("\tStudent Name: " + student.get_name())
print("\tStudent Age: " + str(student.get_age()) + " years")
print("\tStudent Grade: " + str(student.get_grade()))
student.set_name("Jacob Samuel Pomperada")
student.set_age(18)
student.set_grade(88)
print("\n\tUpdated Student Record\n")
print("\tStudent Name: " + student.get_name())
print("\tStudent Age: " + str(student.get_age()) + " years old.")
print("\tStudent Grade: " + str(student.get_grade()))
print("\n\tEnd of Program. Thank you for using this program.")
Friday, September 6, 2024
Thursday, September 5, 2024
Wednesday, September 4, 2024
Tuesday, September 3, 2024
Monday, September 2, 2024
Sunday, September 1, 2024
Subscribe to:
Posts (Atom)