Name: Vineeth Mohan Edukulla
Email: vekfd@umsystem.edu
Write brief explanation here:
Create a class Employee and then do the following:
- Create a constructor to initialize:
- id, name, department, salary, balance, and isEmployed=True.
- Create a class attribute to count the number of Employees.
- Create a Full_time and Part_time Employee classes and it should inherit the properties of Employee class.
- Call init method of the parent class to create an object in these classes.
- Create giveRaise method for Full_time and Part_time classes. The full_time emp. Should have a default value of 10% increase and Part_time should have a default value of 5% increase.
- Create the following functions:
- Pay: This should pay the employee once. Their balance should increase by the amount they are paid.
- Fire: this should remove the employee from the payroll. It should set their payrate to 0, and
isEmployed to false.
- (Note: Retain the records for the employee, just make sure they aren’t paid anymore.)
- isEmployed: a Boolean function that should return if they are employed or not.
- Read employee data from input.txt to create instances of the Employee class:
- File structure:
- NEW: keyword to create a new employee following: ID, Name, Department, Salary, Type(Full_time “F”, Part_time “P”).
- RAISE: keyword to give raise to a specific employee following: ID, raise_percentage that will change the emp. salary.
- PAY: keyword to pay all employee once, balance should increase by the amount they are paid (salary).
- FIRE: Keyword to remove the employee from payroll. Emp. Following is Emp. ID
- File structure:
- Create a function to find the average salary paid to all employees of each class. Write the average salary paid to the end of output.txt file after printing the total number of employees.
- Your program should output data to output.txt with the following format:
- Emp. Name, ID ###, Department:
- If employed, write out their Salary in this format: Current salary: $##
- If NOT employed, you should write out: Not employed with the company.
- The employee’s balance to date: Pay earned to date: $##
- Full-Time or part-time employee.
- Add a blank line between employees.
- ….
- Total number of employees: ###
- Average Salary paid to all Full-time employees: $###
- Average Salary paid to all Part-time employees: $###
Web scraping Write a simple program that parse a Wiki page mentioned below and follow the instructions: https://en.wikipedia.org/wiki/Machine_learning
- Print out the title of the page
- Find all the links in the page (‘a’ tag)
- Iterate over each tag(above) then return the link using attribute "href" using get
- Python 3
- Github Desktop
- pycharm
- Developed the code for the problems and pushed the code file , video and screenshots to the github using github desktop.
Created the parent and child classes as per the question details
class Employee:
# to get the count of employees
countOfEmployees = 0
# Initialise the partime or full time employee data using the parent class EMployee
def __init__(self, empID, name, department, salary, balance):
self.empID = empID
self.name = name
self.department = department
self.salary = salary
self.balance = balance
self.isEmployed = True
self.__class__.countOfEmployees = self.__class__.countOfEmployees + 1
# function is used to check if the employee is employed or not
def isEmployed(self):
return self.isEmployed
# this method is used to fire the employee by changing the status of the isemployed = false
def fire(self):
self.isEmployed = False
self.salary = 0
# This method takes the percentage as input and raises its salary by that percentage.
def giveRaiseByP(self, percent):
self.salary = self.salary + (self.salary * percent) / 100
# pay method will add the salary to the balance when called.
def pay(self):
self.balance = self.balance + self.salary
# declaration of FullTimeEmployee which is child class of Employee
class FullTimeEmployee(Employee):
# used to differentiate the part time and full time employee
Emptype = 'F'
#FullTimeEmployee constructor
def __init__(self, empID, name, department, salary, balance):
# We will use the parent class to intialize the full time employee object
super().__init__(empID, name, department, salary, balance)
# The method is used to raise the percentage of the salary by 10% for full time employee
def giveRaise(self):
self.salary = self.salary + (self.salary / 10)
# declaration of PartTimeEmployee which is child class of Employee
class PartTimeEmployee(Employee):
# used to differentiate the part time and full time employee
Emptype = 'P'
# PartTimeEmployee constructor
def __init__(self, empID, name, department, salary, balance):
super().__init__(empID, name, department, salary, balance)
# The method is used to raise the percentage of the salary by 10% for full time employee
def giveRaise(self):
self.salary = int(self.salary) + int(self.salary) / 20for line in inputData:
# split() method to split the line into words
words = line.split(' ')
# NEW indicates to create an employee
if words[0] == "NEW":
if words[6].rstrip() == "F":
# based on the input 'F' from the file we are creating full time object
fullTimeEmployee = FullTimeEmployee(words[1], words[2] + " " + words[3], words[4], int(words[5]), 0)
# appended the object to the list
employeesList.append(fullTimeEmployee)
if words[6].rstrip() == "P":
# based on the input 'F' from the file we are creating full time object
partTimeEmployee = PartTimeEmployee(words[1], words[2] + " " + words[3], words[4], int(words[5]), 0)
# appended the object to the list
employeesList.append(partTimeEmployee)
# RAISE indicates to raise the amount of salary based on input
elif words[0] == "RAISE":
if len(words) > 2:
for emp in employeesList:
# iterated over the employee list to find the particular employee to raise
if emp.empID == words[1].rstrip():
emp.giveRaiseByP(int(words[2].rstrip()))
break
else:
for emp in employeesList:
if emp.empID == words[1].rstrip():
emp.giveRaise()
# PAY indicated to pay the salary to the employee
elif words[0].rstrip() == "PAY":
for emp in employeesList:
# iterated over all the employees and payed the salaries to the balance.
emp.pay()
# FIRE indicates to remove the employee.
elif words[0] == "FIRE":
for emp in employeesList:
# iterated over the employee list to find the particular employee to fire
if emp.empID == words[1].rstrip():
emp.fire()
breakGathered all the data and pushed to the output file.
Web Scraping
We have used BeautifulSoup and requests library to fetch the information from the website and parse the html content.
import requests
from bs4 import BeautifulSoup
# used get request to download the content in the response.
html = requests.get("https://en.wikipedia.org/wiki/Machine_learning")
# below line is used to parse the HTML content
beautifulObj = BeautifulSoup(html.content, "html.parser")
# printed the title of the web page
print(beautifulObj.title.string)
# finding the <a/> tags from the page and printing it to console
print(beautifulObj.findAll('a'))
# iterating through all the <a/> tags and get the href links
for link in beautifulObj.findAll('a'):
# printing all the href's to console.
print(link.get('href'))Below is the output prinitng the 'a' tags and href's in the website

Code Explanation Video:
https://github.com/UMKC-APL-PythonDeepLearing/icp-3-vekfd/tree/master/Video%20Explanation
Git video location: https://github.com/UMKC-APL-PythonDeepLearing/icp-3-vekfd/raw/master/Video%20Explanation/icp3.mp4

