Skip to content

Commit b62c047

Browse files
authored
Update Day_12.md
1 parent 95da95a commit b62c047

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Status/Day_12.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ print (squaredNumbers)
3232
***Define a class named American which has a static method called printNationality.***
3333

3434
---------------------
35-
### Hints: Use @staticmethod decorator to define class static method.
35+
### Hints: Use @staticmethod decorator to define class static method.There are also two more methods.To know more, go to this [link](https://realpython.com/blog/python/instance-class-and-static-methods-demystified/).
36+
3637
---------------------
3738
**Main Author's Solution: Python 2**
3839
```
@@ -48,6 +49,17 @@ American.printNationality()
4849
--------------------------
4950
**My Solution: Python 3**
5051
```
52+
class American():
53+
@staticmethod
54+
def printNationality():
55+
print("I am American")
56+
57+
american = American()
58+
american.printNationality() # this will not run if @staticmethod does not decorates the function.
59+
# Because the class has no inctance.
60+
61+
American.printNationality() # this will run even though the @staticmethod
62+
# does not decorate printNationality()
5163
```
5264
----------------------------------------
5365

0 commit comments

Comments
 (0)