Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bf1a72a

Browse files
Merge pull request #12 from wcupped/master
Added OOP Example and added me as a contributor on README.MD
2 parents 4fb5a78 + b1da61a commit bf1a72a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

‎OOP Example/main.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Class Creation
2+
class Person:
3+
# Initialization function (when you create an object this named initialization)
4+
def __init__(self,name,age):
5+
# changing objects attributes to arguments that we enter when calling an class to create an object
6+
self.name = name
7+
self.age = age
8+
9+
# String function that returns a string that will be returned if you will print class
10+
# Without __str__(): <__main__.Person object at 0x000001AC025E7230>
11+
# With __str__():
12+
def __str__(self):
13+
return f'Name: {self.name}. Age: {self.age}'
14+
15+
# Creating an object using class
16+
p = Person("John",21) # you can change the values and create some other methods in class
17+
print(p)
18+
19+
# Output:
20+
# Name: John. Age: 21

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ flowchart LR
8181
<td align="center" valign="top" width="14.28%"><a href="https://github.com/levoski1"><img src="https://avatars.githubusercontent.com/u/113690452?v=4?s=100" width="100px;" alt="levoski1"/><br /><sub><b>Ugwoke Levi</b></sub></a><br /><a href="https://github.com/victorpreston/Python-Projects/commits?author=levoski1" title="Code">💻</a></td>
8282
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Manavalan2517"><img src="https://avatars.githubusercontent.com/u/112639423?v=4" width="100px;" alt="Manavalan"/><br /><sub><b>Manavalan</b></sub></a><br /><a href="https://github.com/Manavalan2517" title="Code">💻</a></td>
8383
<td align="center" valign="top" width="14.28%"><a href="http://github.com/P0Saurabh"><img src="https://avatars.githubusercontent.com/u/111894219?v=4?s=100" width="100px;" alt="P0Saurabh"/><br /><sub><b>P0Saurabh</b></sub></a><br /><a href="https://github.com/victorpreston/Python-Projects/commits?author=P0Saurabh" title="Code">💻</a></td>
84+
<td align="center" valign="top" width="14.28%"><a href="http://github.com/wcupped"><img src="https://avatars.githubusercontent.com/u/134646828?v=4?s=100" width="100px;" alt="wCupped"/><br /><sub><b>wCupped</b></sub><br />💻</a></td>
8485
</tr>
8586
</tbody>
8687
</table>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /