py icp3 - koushikskr/python GitHub Wiki

Title : Object Oriented Python

Question 1:

Create a class Employee and perform OOPS operations

Steps:

Created a class called Student with the properties name,family, salary and department and a class variable num_of_emps to get the count

Created a method name avg_sal to get the average salary of the employees. List of employees will be the input parameter to this method and loop through each of the employee object to get the salary and computed average.

Created a child class called Full Time_Employee and inherited Employee class and initialized with the parent class properties along with the newly created property company in constructor.

Created get_company method in the child class which takes the employee list and a name of the employee to find out the company of the employee passed.

created objects for Employee and Full Time_Employee class and called the methods to get the desired results.

Question 2

Web scraping of wiki page

steps:

Using the Beautiful Soup got the content of the page

Got the title of the page with the id associated to the heading in the page.

To find out links, looped through each of the a tag in the page and got href tag stored them in a file.

Question 3

Numpy

steps:

Created a random array with float values and with the size of 20

Using reshape method created a two dimensional array 4 by 5

Using max function of numpy, replaced the max values of each row of a reshape array with 0.