OOP01_Class_Definition_and_Object_Instantiation.py
python_old/OOP01_Class_Definition_and_Object_Instantiation.py
class Person:
def __init__(self, name, age): # constructor
self.name = name
self.age = age
print("Person object created.")
def greet(self):
print(f"Hi, I'm {self.name} and I'm {self.age} years old.")
def __del__(self): # destructor
print("Person object deleted.")
## End class definition
if __name__ == "__main__": # main function <- program entry point
person_john = Person("John", 30) # object instantiation, instance to an object
person_vicky = Person("Vicky", 25) # object instantiation, instance to an object
person_john.greet()
person_vicky.greet()
관련 글
01_classical_caesar_cipher.py
01_classical_caesar_cipher.py — python source code from the python old learning materials (python_old/Cryptography/01_classical_caesar_cipher.py).
글 읽기 →02_classical_monoalphabetic.py
02_classical_monoalphabetic.py — python source code from the python old learning materials (python_old/Cryptography/02_classical_monoalphabetic.py).
글 읽기 →03_classical_rail_fence.py
03_classical_rail_fence.py — python source code from the python old learning materials (python_old/Cryptography/03_classical_rail_fence.py).
글 읽기 →04_frequency_analysis.py
04_frequency_analysis.py — python source code from the python old learning materials (python_old/Cryptography/04_frequency_analysis.py).
글 읽기 →05_cryptographic_hashing.py
05_cryptographic_hashing.py — python source code from the python old learning materials (python_old/Cryptography/05_cryptographic_hashing.py).
글 읽기 →06_password_hashing.py
06_password_hashing.py — python source code from the python old learning materials (python_old/Cryptography/06_password_hashing.py).
글 읽기 →