[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2025-01-17 19:21:50 +00:00
parent 5443c8ec21
commit 272d6248a4

View File

@ -1,20 +1,21 @@
# Class Creation # Class Creation
class Person: class Person:
# Initialization function (when you create an object this named initialization) # Initialization function (when you create an object this named initialization)
def __init__(self,name,age): def __init__(self, name, age):
# changing objects attributes to arguments that we enter when calling an class to create an object # changing objects attributes to arguments that we enter when calling an class to create an object
self.name = name self.name = name
self.age = age self.age = age
# String function that returns a string that will be returned if you will print class # String function that returns a string that will be returned if you will print class
# Without __str__(): <__main__.Person object at 0x000001AC025E7230> # Without __str__(): <__main__.Person object at 0x000001AC025E7230>
# With __str__(): # With __str__():
def __str__(self): def __str__(self):
return f'Name: {self.name}. Age: {self.age}' return f"Name: {self.name}. Age: {self.age}"
# Creating an object using class # Creating an object using class
p = Person("John",21) p = Person("John", 21)
print(p) print(p)
# Output: # Output:
# Name: John. Age: 21 # Name: John. Age: 21