Class variables

Class variables are the ones, which are sharable among all the instances of the class. The class variable must be the same for all the instances. To understand with example, let's assume that leapx_org gives 5 percent increment based upon pay_amt. Let's use another method to calculate the increment. Refer to the classinstance1.py program:

class Leapx_org():  def __init__(self,first,last,pay):    self.f_name = first    self.l_name = last    self.pay_amt = pay     self.full_name = first+" "+last  def make_email(self):    return self.f_name+ "."+self.l_name+"@xyz.com"  def incrementpay(self):    self.pay_amt = int(self.pay_amt*1.20)    return self.pay_amtL_obj1 = Leapx_org('mohit', 'RAJ', 60000)L_obj2 = Leapx_org('Ravender', 'Dahiya',70000) print L_obj1.pay_amt ...

Get Learn Python in 7 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.