Skip to content

Commit 9187d09

Browse files
Class And Its Objects & Methods
0 parents  commit 9187d09

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

code/Class objects and methods.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#Class objects and methods
2+
3+
class Person:
4+
name=""
5+
6+
def setName(self,name):
7+
self.name=name
8+
9+
def getName(self):
10+
return self.name
11+
12+
def greet(self):
13+
return "Hello {}".format(self.name)
14+
15+
16+
p=Person()
17+
18+
print(p.name)
19+
p.setName("Vaibhav")
20+
print(p.name)
21+
p.setName("Ri")
22+
print(p.name)
23+
24+
p2=Person()
25+
26+
print(p2.name)
27+
p2.setName("Ha")
28+
print(p2.name)
29+
p2.setName("Hp")
30+
print(p2.name)
31+
32+
33+

output/output.png

835 KB
Loading

0 commit comments

Comments
 (0)