Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # class , obj
- # -------------
- # with constructor
- # -----------------
- # class Person():
- # def __init__(self, fname, lname, idd):
- # self.fname = fname
- # self.lname = lname
- # self.id = idd
- # self.email = idd + '@gmail.com'
- # def info(self):
- # return ('firstname: {} , lastname: {}, id: {}, email: {}'.format(self.fname, self.lname, self.id, self.email))
- # p1 = Person('riju', 'chowdhury', '2015-1-60-169')
- # print(p1.info())
- # with fn
- # ---------
- # class Person():
- # def info(self, fname, lname, idd):
- # self.fname = fname
- # self.lname = lname
- # self.id = idd
- # self.email = idd + '@gmail.com'
- # return ('{} {} {} {}'.format(self.fname, self.lname, self.id, self.email))
- # p1 = Person()
- # print(p1.info('riju', 'chowdhury', '2015-1-60-169'))
- # variable
- # -----------
- class Person():
- amount = 2.04
- def info(self, fname, lname, idd):
- self.fname = fname
- self.lname = lname
- self.id = idd
- self.email = idd + '@gmail.com'
- return ('{} {} {} {}'.format(self.fname, self.lname, self.id, self.email))
- # def salaryCalc(self, salary):
- # self.total = salary * 2.04
- # return ('salary: {}'.format(self.total))
- def salaryCalc(self, salary):
- self.total = salary * Person.amount # call variable
- return ('salary: {}'.format(self.total))
- p1 = Person()
- print(p1.info('riju', 'chowdhury', '2015-1-60-169'))
- print(p1.salaryCalc(6000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement