class example
This commit is contained in:
parent
3cd256fc5f
commit
e2382b1bc1
1
latest_chapter.txt
Normal file
1
latest_chapter.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Sınıfın Öznitelikleri ve Nesnenin Örnek Öznitelikleri sayfa 219
|
15
python-temel/class.example.py
Normal file
15
python-temel/class.example.py
Normal 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
|
Loading…
Reference in New Issue
Block a user