본문 바로가기
728x90
반응형
SMALL

개념/혼자 공부하는 파이썬30

python) Understanding the Test Class and Its Behavior class Test: def __init__(self, name): self.name = name print("{} - generate".format(self.name)) def __del__(self): print("{} - delete".format(self.name)) Test("A") Test("B") Test("C") ### Understanding the Test Class and Its Behavior This snippet demonstrates the creation and deletion of objects in Python, using a class named `Test`. Here's an explanation of each part: 1. **`class Test:`** Defin.. 2024. 11. 9.
python) Detailed Breakdown of the Modified Test Class Usage class Test: def __init__(self, name): self.name = name print("{} - generate".format(self.name)) def __del__(self): print("{} - delete".format(self.name)) a = Test("A") b = Test("B") c = Test("C") ### Detailed Breakdown of the Modified Test Class Usage In this modified version of the code, instances of the `Test` class are assigned to variables `a`, `b`, and `c`. This has implications for the obj.. 2024. 11. 8.
python) Explanation of the Code Using a Dictionary to Represent Students def create_student(name, korean, math, english, science): return { "name": name, "korean": korean, "math": math, "english":english, "science": science } students = [ create_student("윤인성", 87,98,88,95), create_student("연하진",92,98,96,98), create_student("구지연",98,96,90,89), create_student("나선주",88,86,64,87), create_student("윤아린",98,99,78,80), ] print("name", "total", "average", sep="\t") for studen.. 2024. 11. 7.
python) Explanation of the Improved Student Management Code def create_student(name,korean,math,english,science): return{ "name":name, "korean":korean, "math":math, "english":english, "science":science } def student_get_sum(student): return student["korean"]+student["math"]+student["english"]+student["science"] def student_get_average(student): return student_get_sum(student)/ len(student) def student_to_string(student): return "{}\t{}\t{}".format(studen.. 2024. 11. 6.
728x90
반응형
LIST