ICP3 - narhirep/Python-Deep-Learning GitHub Wiki

Welcome to In Class Programming 3 Python:

Description: This assignment involves writing a code by making use of class and inheritance concept. Also we are going to use web-scraping concept to get the content from wiki. We will use Numpy python built-in functions for array operations.

Objective: To get to know about object oriented concepts, classes, inheritance, Web scraping and Numpy inbuilt functions.

Implementation:

Question 1. Create a class Employee and then do the following

  • Create a data member to count the number of Employees
  • Create a constructor to initialize name, family, salary, department
  • Create a function to average salary
  • Create a Full time Employee class and it should inherit the properties of Employee class
  • Create the instances of Full time Employee class and Employee class and call their member functions.

Below is the code for implementing question 1 where I have created a data member to count the number of Employees and a constructor to initialize name, family, salary, department. Also created a function to average the salary which uses class variables number of employees and total salary. The instances of full time Employee class calls the functions of its class as well as its parent class.

Code

Code

Output of the code:

Output

Question 2.

Web scraping Write a simple program that parse a Wiki page mentioned below and follow the instructions:https://en.wikipedia.org/wiki/Deep_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
  • Save all the links in the file

So as per question I have parsed the wiki page https://en.wikipedia.org/wiki/Deep_learning by using request.get() function and BeautifulSoup and printed title of the page as well as printed/saved all of the links from wiki page with mentioned criteria in link.txt file.

Code

Output of the code:

Output

Question 3.

Numpy Using NumPy create random vector of size 20 having only float in the range 1-20. Then reshape the array to 4 by 5. Then replace the max in each row by 0(axis=1)

So a random vector is created as shown in below code of size 20 with limits of number 1-20. Then it is reshaped to array of 4 by 5. After that for each row maximum number is replaced by 0.

Code and Output

Video Link: Video Link

Conclusion: So in this ICP i have learned about object oriented concepts, classes, inheritance, Web scraping and Numpy inbuilt functions.