player.py
class Player:
    teamName = 'Rajasthan Royals'  # class variables
    

    def __init__(self, name, pre_teams=[]):
        self.name = name  # creating instance variables
        self.previous_teams = pre_teams
    
    def list_previous_teams(self): # instance method
        for team in self.previous_teams:
            print(team)

    @classmethod
    def getTeamName(cls): # class method
        return cls.teamName

    @staticmethod
        def calculate_bmi(): # static method
            print("I am a static method.")
            
            
  player_1 = Player('Sanju Samson', ['DD'])
  player_1.list_previous_teams()          
    

Methods in

1. Instance

2. Class

3. Static

Python

Afiz ⚡️

@itsafiz

Twitter icon

Class Name

Create Object

Calling Instance method

Class Variable

Instance Methods: These methods are bound to

instance(object) of the class

Static Method: These utility methods

nothing to do with class or instance

Class Method: work with class variables

and are accessible using the name rather

than its object

Afiz