Python OOP Tutorial - 2. Class Variables

  1. Run Code 1 in Python

Run Code 1 in Python

# file: 'start2.py'
class Employee:

    def __init__(self, first, last, pay):
        self.first = first
        self.last = last
        self.email = first + '.' + last + '@email.com'
        self.pay = pay

    def fullname(self):
        return '{} {}'.format(self.first, self.last)

emp_1 = Employee('Corey', 'Schafer', 50000)
emp_2 = Employee('Test', 'Employee', 60000)

start2.py

Comments 💬