python-CSD-kursu/python-temel/class.example.py
2023-06-25 15:29:28 +03:00

16 lines
544 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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