From 5ba36f1e878fa37ddec8e4ca1613cc33b477bfdd Mon Sep 17 00:00:00 2001 From: mimikaan Date: Sat, 20 Oct 2018 22:47:14 +0530 Subject: [PATCH] Update index.md (#21773) A simple implementation of class and object in python. --- guide/english/python/class/index.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/guide/english/python/class/index.md b/guide/english/python/class/index.md index 52104ac293..70108644b9 100644 --- a/guide/english/python/class/index.md +++ b/guide/english/python/class/index.md @@ -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() +```