Skip to content

Commit 97cd6b6

Browse files
author
Ashwin Hegde
committed
Merge pull request #4 from hegdeashwin/develop
Adds objects eg
2 parents 70154e1 + 3093d59 commit 97cd6b6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

codes/ch1_syntax/objects.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/python3
2+
3+
class Profile:
4+
def __init__(self, name = "Unknown", age = 18):
5+
self.name = name
6+
self.age = age
7+
8+
def whatName(self):
9+
return self.name
10+
11+
def whatAge(self):
12+
return self.age
13+
14+
def main():
15+
myProfile = Profile()
16+
print(myProfile.whatName(), myProfile.whatAge())
17+
18+
github = Profile('Ashwin Hegde', age = 26)
19+
print(github.whatName(), github.whatAge())
20+
21+
22+
if __name__ == "__main__": main()

0 commit comments

Comments
 (0)