Python OOP Tutorial - 1. Classes and Instances

Table of Contents

  1. Run Code 1 in Python

Run Code 1 in Python

1
2
3
4
5
6
7
8
9
10
11
12
13
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)

start.py