class example

This commit is contained in:
Mert Gör 🇹🇷 2023-06-25 15:29:28 +03:00
parent 3cd256fc5f
commit e2382b1bc1
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
2 changed files with 16 additions and 0 deletions

1
latest_chapter.txt Normal file
View File

@ -0,0 +1 @@
Sınıfın Öznitelikleri ve Nesnenin Örnek Öznitelikleri sayfa 219

View File

@ -0,0 +1,15 @@
class Student:
x = 10 # sınıf özniteliği, sınıfın bir elemanı, nesnenin değil
print(x) # sınıf özniteliği olan x kullanılıyor
def __init__(self, name, no):
self.name = name
self.no = no
def disp(self):
print("İsim = {}, No = {}".format(self.name, self.no))
print("x = {}".format(Student.x)) # x değil, Student.x
s = Student("Ali Serçe", 123)
s.disp()
print("x = {}".format(Student.x)) # x değil, Student.x