Skip to content

Commit dc29fb6

Browse files
Corey SchaferCorey Schafer
Corey Schafer
authored and
Corey Schafer
committed
Added common starting code for tutorials
1 parent 34653e5 commit dc29fb6

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

Starting_Code/calc.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
def add(x, y):
3+
"""Add Function"""
4+
return x + y
5+
6+
7+
def subtract(x, y):
8+
"""Subtract Function"""
9+
return x - y
10+
11+
12+
def multiply(x, y):
13+
"""Multiply Function"""
14+
return x * y
15+
16+
17+
def divide(x, y):
18+
"""Divide Function"""
19+
return x / y

Starting_Code/employee.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
class Employee:
3+
"""A sample Employee class"""
4+
5+
num_of_emps = 0
6+
raise_amt = 1.04
7+
8+
def __init__(self, first, last, pay):
9+
self.first = first
10+
self.last = last
11+
self.pay = pay
12+
13+
Employee.num_of_emps += 1
14+
15+
@property
16+
def email(self):
17+
return '{}.{}@email.com'.format(self.first, self.last)
18+
19+
@property
20+
def fullname(self):
21+
return '{} {}'.format(self.first, self.last)
22+
23+
def apply_raise(self):
24+
self.pay = int(self.pay * self.raise_amt)
25+
26+
def __repr__(self):
27+
return "Employee('{}', '{}', {})".format(self.first, self.last, self.pay)
28+
29+
30+
class Manager(Employee):
31+
"""A sample Manager class"""
32+
33+
def __init__(self, first, last, pay, employees=None):
34+
super().__init__(first, last, pay)
35+
self.employees = employees if employees else []
36+
37+
def add_emp(self, emp):
38+
if emp not in self.employees:
39+
self.employees.append(emp)
40+
41+
def remove_emp(self, emp):
42+
if emp in self.employees:
43+
self.employees.remove(emp)
44+
45+
def __repr__(self):
46+
return "Manager('{}', '{}', {}, {})".format(self.first, self.last, self.pay, self.employees)

0 commit comments

Comments
 (0)