Update index.md (#21773)

A simple implementation of class and object in python.
This commit is contained in:
mimikaan
2018-10-20 22:47:14 +05:30
committed by Randell Dawson
parent bf760d4508
commit 5ba36f1e87

View File

@ -98,5 +98,18 @@ x.__privatenum # gives following error : 'Foo' object has no attribute '__priva
``` ```
## Simple class and Object Implementation
```python
class Friend:
def __init__(self,first,last,state):
self.fname = first
self.lname = last
self.state = state
self.email = first+"."+state+"@nith.com"
def show(self):
return '{} {} {} {}'.format(self.fname,self.lname,self.state,self.email)
fr1 = Friend("Nilesh","Bharti","Bihar")
fr1.show()
```