<jupyter_start><jupyter_text>Classes with Multiple Objects<jupyter_code>class Birds:
 def __init__(self, bird_name):
  self.bird_name = bird_name

 def flying_birds(self):
  print(f"{self.bird_name} flies above clouds")
 
 def non_flying_birds(self):
  print(f"{self.bird_name} is the national bird of the Philippines")

vulture = Birds("Griffon Vulture")
crane = Birds("Common Crane")
emu = Birds("Emu")

vulture.flying_birds()
crane.flying_birds()
emu.non_flying_birds()<jupyter_output>Griffon Vulture flies above clouds
Common Crane flies above clouds
Emu is the national bird of the Philippines<jupyter_text>Encapsulation(mangling with double underscores)<jupyter_code>class foo:
 def __init__(self, a, b):
  self.__a = a
  self.__b = b
 
 def add(self):
  return self.__a + self.__b

 def sub(self):
  return self.__a - self.__b

foo_object = foo(3, 4)


#print(foo_object.b)
print(foo_object.add()) #adding a and b
print(foo_object.sub()) #subtracting a and b

foo_object.__b = 5
foo_object.__a = 7

print(foo_object.add())
print(foo_object.sub())<jupyter_output>7
-1
7
-1<jupyter_text>Inheritance<jupyter_code>class Person:
 def __init__(self, firstname, surname):
  self.firstname = firstname
  self.surname = surname

 def printname(self):
  print(self.firstname, self.surname)

person = Person("Mam", "Sayo")
person.printname()

class Student(Person):
 pass

person = Student("Asley", "Goce")
person.printname()<jupyter_output><NAME>
<NAME><jupyter_text>Polymorphism<jupyter_code>class RegularPolygon:
 def __init__(self, side):
  self.side = side
class Square(RegularPolygon):
 def area(self):
  return self.side*self.side
class EquilateralTriangle(RegularPolygon):
 def area(self):
  return self.side*self.side*0.433

x = Square(4)
y = EquilateralTriangle(3)

print(x.area())
print(y.area())<jupyter_output>16
3.897<jupyter_text>Application 1 1. Create a Python program that displays the name of three students (Student 1, Student 2, and Student 3) and their term grades2. Create a class name Person and attributes - std1, std2, std3, pre, mid, fin3. Compute the average of each term grade using Grade() method4. Information about student's grades must be hidden from others<jupyter_code>class Person:
 def __init__(self, std1, std2, std3, pre, mid, fin):
  self.__std1 = std1
  self.__std2 = std2
  self.__std3 = std3
  self.__pre = pre
  self.__mid = mid
  self.__fin = fin
 
 def Grade(self):
  return (self.__pre+self.__mid+self.__fin)/3
 
 def show1(self):
  return self.__std1
 
 def show2(self):
  return self.__std2
 
 def show3(self):
  return self.__std3

class Student1(Person):
 def show(self):
  print(f"{self.show1()} average term grade is {self.Grade()}")
  
class Student2(Person):
 def show(self):
  print(f"{self.show2()} average term grade is {self.Grade()}")

class Student3(Person):
 def show(self):
  print(f"{self.show3()} average term grade is {self.Grade()}")

name1 = Student1("<NAME>", None, None, 76, 83, 81)
name1.__std1 = "change"
name1.__pre = 0
name1.show()
  
name2 = Student2(None, "<NAME>", None, 86, 74, 90)
name2.show()

name3 = Student3(None, None, "<NAME>", 75, 70, 79)
name3.show()<jupyter_output><NAME> average term grade is 80.0
<NAME> average term grade is 83.33333333333333
<NAME> average term grade is 74.66666666666667
{'fraction_non_alphanumeric': 0.12698412698412698, 'fraction_numerical': 0.03632478632478633, 'mean_word_length': 5.241904761904762, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '346458', 'license': 'Apache-2.0', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1158, 'n_words': 317, 'path': 'OOP_2.ipynb', 'repo_name': 'martlegaspi/OOP-58002', 'size': '3322'}