Module 1_ICP 3: Object Oriented Python, Web Scraping, and Numpy - acikgozmehmet/PythonDeepLearning GitHub Wiki

Object Oriented Python, Web Scraping, and Numpy

Objectives:

The following topics are covered.

  1. Object Oriented Concepts
    • Classes
    • Instances
    • Init
    • self
    • Private, Protected, Public
    • Inheritance
    • Scientific Python
  2. Numpy Package
  3. Web scraping

Overview

  1. Classes are one of the important concepts of Python. Everything in Python is an Object. Classes enable us to encapsulate data, restrict the scope of data members and functions. They help us in reusability by inheritance. We can define the various level of data encapsulation like private, protected and public.
  2. NumPy is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays. The ancestor of NumPy, Numeric, was originally created by Jim Hugunin with contributions from several other developers. In 2005, Travis Oliphant created NumPy by incorporating features of the competing Numarray into Numeric, with extensive modifications. NumPy is open-source software and has many contributors.
  3. The incredible amount of data on the Internet is a rich resource for any field of research or personal interest. To effectively harvest that data, you’ll need to become skilled at web scraping. The Python libraries requests and Beautiful Soup are powerful tools for the job.

In Class Programming

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 Fulltime Employee class and it should inherit the properties of Employee class

• Create the instances of Fulltime Employee class and Employee class and call their member functions.

Click here to get the source code

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

Click here to get the source code

3. Numpy

  • Using NumPy create random vector of size 15 having only Integers in the range 1-20.
  • Then reshape the array to 3 by 5
  • Then replace the max in each row by 0
  • (you can NOT implement it via for loop. You need to use np.where, reshape)

Click here to get the source code

References

https://github.com/saria85/PythonProgramming-summer2017

https://beautiful-soup-4.readthedocs.io/en/latest/

http://www.w3resource.com/pythonexercises/https://www.slideshare.net/milkers/beautiful-soup?qid=64c9989d-94f7-4811-b3102cd7cfcb272e&v=&b=&from_search=6

https://www.learnpython.org/