Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosfreeCodeCamp.org: TimescaleDB Course – PostgreSQL for Time-Series Data(23.09.2026 um 12:30 Uhr)
Windows Tipps & SecurityAndroid 17: Rollout auf Samsung-Galaxy-Smartphones verzögert sich(23.09.2026 um 11:42 Uhr)
Unix & Linux ServerUSN-8733-2: Gzip vulnerabilities(22.09.2026 um 18:04 Uhr)
Sichere ProgrammierungHow to Build Custom PowerPoint Add-Ins for Enterprise Teams(23.09.2026 um 11:25 Uhr)
Sichere ProgrammierungSearch Google Jobs in Real-Time with Go and SerpApi 🚀(23.09.2026 um 12:13 Uhr)
Sichere ProgrammierungA Psychological State is a Coefficient Vector(23.09.2026 um 12:16 Uhr)
YouTube Security VideosfreeCodeCamp.org: TimescaleDB Course – PostgreSQL for Time-Series Data(23.09.2026 um 12:30 Uhr)
Windows Tipps & SecurityAndroid 17: Rollout auf Samsung-Galaxy-Smartphones verzögert sich(23.09.2026 um 11:42 Uhr)
Unix & Linux ServerUSN-8733-2: Gzip vulnerabilities(22.09.2026 um 18:04 Uhr)
Sichere ProgrammierungHow to Build Custom PowerPoint Add-Ins for Enterprise Teams(23.09.2026 um 11:25 Uhr)
Sichere ProgrammierungSearch Google Jobs in Real-Time with Go and SerpApi 🚀(23.09.2026 um 12:13 Uhr)
Sichere ProgrammierungA Psychological State is a Coefficient Vector(23.09.2026 um 12:16 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Python basics - Day 22

Day 22 – OOP Basics: Class & Object Project: Build a “Student Management App” using Python classes and objects. 01. Learning Goal By the end of this lesson, you will be able to: Understand the core idea of Object-Oriented Progr…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!




Day 22 – OOP Basics: Class & Object



Project: Build a “Student Management App” using Python classes and objects.






01. Learning Goal



By the end of this lesson, you will be able to:




  • Understand the core idea of Object-Oriented Programming (OOP)

  • Define a class and create objects (instances)

  • Use attributes and methods effectively

  • Understand how the __init__() constructor works






02. Problem Scenario



Imagine you’re building a system to manage students in a school.


Each student has a name, an age, and the ability to introduce themselves.


Instead of storing data in plain variables, you’ll group related data and actions together inside a class.





03. Step 1 – What is OOP?



OOP (Object-Oriented Programming) is a paradigm where you model real-world entities as objects.


Each object has:





  • Attributes → data (e.g., name, age)


  • Methods → behaviors or actions (e.g., introduce, study)



In Korean:


객체지향 프로그래밍(OOP)은 현실 세계의 개체를 객체(object) 로 모델링하는 방식으로,


객체는 속성(데이터)메서드(동작) 를 가진다.





04. Step 2 – Defining a Class



Let’s define a simple Student class with attributes and methods.




class Student:
def __init__(self, name, age): # Constructor
self.name = name # Attribute
self.age = age

def introduce(self): # Method
print(f"My name is {self.name}, I am {self.age} years old.")









05. Step 3 – Creating Objects



A class is just a blueprint — we create objects (instances) from it.




s1 = Student("Sabin", 30)
s2 = Student("Anna", 22)

s1.introduce() # My name is Sabin, I am 30 years old.
s2.introduce() # My name is Anna, I am 22 years old.









06. Step 4 – The __init__() Constructor



The __init__() method runs automatically whenever an object is created.

It initializes the object’s attributes.




class Car:
def __init__(self, brand, model):
self.brand = brand
self.model = model

car1 = Car("Tesla", "Model 3")
print(car1.brand, car1.model) # Tesla Model 3









07. Step 5 – Attributes & Methods



Attributes store data; methods define actions.




class Dog:
def __init__(self, name):
self.name = name

def bark(self):
print(f"{self.name} is barking! / {self.name}가 짖고 있어요!")

d = Dog("Buddy")
print(d.name) # Buddy
d.bark() # Buddy is barking! / Buddy가 짖고 있어요!









08. Step 6 – Practice Examples



Example 1: Book Class




class Book:
def __init__(self, title, author):
self.title = title
self.author = author

def info(self):
print(f"'{self.title}' written by {self.author}")

b = Book("Python Basics", "Sabin")
b.info()






Output:




'Python Basics' written by Sabin









Example 2: Calculator Class




class Calculator:
def add(self, a, b):
return a + b

def sub(self, a, b):
return a - b

calc = Calculator()
print(calc.add(10, 5)) # 15
print(calc.sub(10, 5)) # 5









09. Step 7 – Mini Project: Student Management App



Let’s expand our Student class to include a grade and a study method.




class Student:
def __init__(self, name, age, grade):
self.name = name
self.age = age
self.grade = grade

def introduce(self):
print(f"My name is {self.name}, I’m {self.age} years old and in grade {self.grade}.")

def study(self, subject):
print(f"{self.name} is studying {subject}!")

s = Student("Sabin", 30, "A")
s.introduce()
s.study("Python")






Output:




My name is Sabin, I’m 30 years old and in grade A.
Sabin is studying Python!









10. Reflection



You have learned how to:




  • Define and instantiate classes

  • Use attributes and methods to represent data and behavior

  • Understand how the __init__() constructor works

  • Build your first object-oriented program



Next → Day 23 – OOP: Class Variables & Methods

Learn how to share data across all instances using class-level attributes and methods.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Python basics - Day 22

Thematisch verwandte Begriffe: Python, basics · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-96258 | A vulnerability has been found in onSite internet GmbH Auktion NG Auktio…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick