GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Added common starting code for tutorials · kumar-samang/code_snippets@dc29fb6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Starting_Code
    • calc.py
    • employee.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Starting_Code/calc.py‎

Copy file name to clipboard
+19Lines changed: 19 additions & 0 deletions
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
Collapse file

‎Starting_Code/employee.py‎

Copy file name to clipboard
+46Lines changed: 46 additions & 0 deletions
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 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.