Skip to content

Commit 272d624

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 5443c8e commit 272d624

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

other/oop_example.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# Class Creation
22
class Person:
33
# Initialization function (when you create an object this named initialization)
4-
def __init__(self,name,age):
4+
def __init__(self, name, age):
55
# changing objects attributes to arguments that we enter when calling an class to create an object
66
self.name = name
77
self.age = age
88

99
# String function that returns a string that will be returned if you will print class
1010
# Without __str__(): <__main__.Person object at 0x000001AC025E7230>
11-
# With __str__():
11+
# With __str__():
1212
def __str__(self):
13-
return f'Name: {self.name}. Age: {self.age}'
14-
13+
return f"Name: {self.name}. Age: {self.age}"
14+
15+
1516
# Creating an object using class
16-
p = Person("John",21)
17+
p = Person("John", 21)
1718
print(p)
1819

1920
# Output:
20-
# Name: John. Age: 21
21+
# Name: John. Age: 21

0 commit comments

Comments
 (0)