Machine Learning from Scratch with Python, Scikit-Learn & PyTorch by Bemnet Girma
CHAPTER TWO
Hello Python
Objectives
What is Python?
Why we study Python?
What are the key features of Python?
What are applications of Python?
How to install jupyter notebook?
keyboard_arrow_down Lesson One : Introduction to Python
To better communicate with a computer you should have to learn a programming language, Even
though you have translators like compiler and interpreter. But which programming language? The
answer would be simple, used for different / multiple purposes, i.e. Python.
What is Python?
Python is simple, general purpose, dynamic, object oriented, interpreted as well as compiled, high-
level programming language.
In details Python is
Simple – It is easy to learn and code.
General purpose – It can be used to build just about anything.
High level language – It is human readable language which easily understandable and
Easy to debug – It is easy to check and correct your error.
Dynamic – You don’t need to write everything to instruct your computer.
Object Oriented – Structure of python program can be grouped based on its behavior.
Interpreted as well as compiled – Python is basically called an interpreted language, but can
also be called a compiled interpreted language.
In Python, first source code compiles into a bytecode then bytecode is sent for execution to PVM
(Python Virtual Machine). The PVM is an interpreter that runs the bytecode.
Why we study Python?
Because Python is
One of easiest language
Fastest growing language
Vast implementation areas
Used in many companies
History or Origin of Python
It was invented in the Netherlands in the early 90’s.
Guido Van Rossum was the creator of this beautiful language.
Guido released the first version in 1991.
Python was derived from ABC programming language, a general purpose programming
language.
It is open source software which can be downloaded freely and the code is customizable as
well.
Why the name Python?
💡 There was a TV show by the name Monty Python’s Flying Circus which was a very much popular
fun show in the 1970’s. While creating Python, Guido also used to read this show’s published scripts.
Guido needed a short and a different name for this language, hence he named it “Python”.
Python Versions
Python 1.0V introduced in Jan 1994
Python 2.0V introduced in October 2000
Python 3.0V introduced in December 2008.
Current version is 3.12 (Feb 2024)
PS. Python 3 won’t provide backward compatibility to Python2 i.e. there is no guarantee that
Python2 programs will run in Python3.
Features of Python
Simple - Python syntax is very easy. Developing and understanding python is very easy than
others. The below comparison illustrated how simple python language is when compared to
other languages.
Hello World Program in C language
# include <stdio.h>
int main()
{
printf("Hello World")
return 0
}
Hello World Program in Python
print("Hello World")
Open Source - We can download freely and customize the code as well
Platform independent - Python programs are not dependent on any specific operating
systems. We can run on all operating systems happily.
Portable - If a program gives the same result on any platform then it is a portable program.
Python used to give the same result on any platform.
Huge library - Python has a big library to fulfil the requirements.
Database connectivity - Python provides interfaces to connect with all major databases like,
oracle, MySQL.
keyboard_arrow_down Lesson Two : Applications of Python
Python is a programming language that does it all, from web applications to video-games, Data
Science, Machine Learning, real-time applications to embedded applications, and so much more. In
this lesson, we’ll take a deeper dive into a broader list of applications of Python out in the wild.
1. Web Development
I hope you are familiar with what web development is. Python is used to develop fully functional
website using web development frameworks like Flask and Django. Using Python for web
development also offers several other benefits, such as security, easy scalability, and convenience in
the development process.
2. Game Development
Just like web development, Python comes equipped with an arsenal of tools and libraries for 2D, 3D
and video game development like PyGame.
3. AI and Machine Learning
Artificial Intelligence(AI) and Machine Learning are undoubtedly among the hottest topics of this
decade. These are the brains behind the smart tech that we so rely on today to help us make
optimized decisions. Python has seen a steep increase in their use for developing AI and ML-
powered solutions like YouTube video recommendations. We have TensorFlow, PyTorch, Pandas,
Scikit-Learn, NumPy, SciPy, and more libraries.
4. Desktop and Mobile Applications
Python offers plenty of options to desktop and mobile application developers to build super-fast,
responsive and fully functional GUI using tools like Tkinter and Kivy.
5. Image Processing
Due to the ever-increasing use of Machine Learning, the role of image (pre)processing tools has also
skyrocketed. To fulfill this demand, Python offers a host of libraries that are useful for multiple
applications like face recognition & image detection. Some of the popular image processing Python
libraries include OpenCV and Python Imaging Library(PIL).
6. Text Processing
Text Processing is among the most common uses of Python. Text Processing allows you to handle
enormous volumes of text while giving you the flexibility to structure it as you wish. Do you ever
think how facebook detects hate speech posts and comments? Well, that has done with Python’s text
processing capabilities.
7. Audio and Video Applications
When it comes to working with audio and video files, python is fully equipped with tools and
libraries to accomplish your task. Tasks such as basic signal processing, creative audio manipulation,
audio recognition, and more can be easily handled by libraries like Pyo, pyAudioAnalysis, Dejavu,
and many other libraries like it.
As for the video part, Python offers several libraries, such as Scikit-video, OpenCV, and SciPy, that
can help you manipulate and prepare videos for use in other applications. Popular audio & video
streaming applications like Spotify, Netflix, and YouTube are written in Python.
8. Web Scraping Applications
The internet is home to an enormous amount of information ready to be utilized. What Web Scrapers
essentially do is they crawl the websites they’re directed towards and store all the collected
information from their web pages in one place. From there onwards, this data could be used by
researchers, analysts, individuals, organizations for a broad range of tasks. A few examples of the
tools behind the Web Scrapers are PythonRequest, BeautifulSoup and Selenium.
9. Data Science and Data Visualization
Data plays a decisive role in the modern world. Why? because it is key to understanding the people
and their taste in things around them by gathering and analyzing crucial insights about them. This is
what the entire domain of Data Science revolves around. Data Science involves identifying the
problem, data collection, data processing, data exploration, data analysis, and data visualization.
The Python ecosystem offers several libraries that can help you tackle your Data Science problems
head-on. We have Matplotlib and Seaborn as the most widely used data visualization tools.
10. Scientific and Numeric Applications
AI, ML, and Data Science projects still require intensive computations in the form of linear algebra,
high-level mathematical functions, and similar, Python is well equipped for them too. Python helped
scientists and researchers conclude countless number-crunching problems and uncover new
findings. FreeCAD and Abaqus are some realworld examples of numerical and scientific
applications built with Python.
Conclusion
Python is an extremely robust and versatile programming language that is rapidly gaining popularity
among developers from various sectors. Its ability to be deployed into virtually any domain is
remarkable, thanks to its vast ecosystem of diverse libraries.
keyboard_arrow_down Lesson Three : Python Installation
Python IDEs are software applications that provide tools and features to facilitate coding in Python.
They offer features like code writing, execution, debugging, making the development process more
efficient.
Jupyter Notebook
Jupyter Notebook is an open source web application that you can use to create and share live code. It
is a popular IDE for data science and machine learning tasks.
How to install Jupyter Notebook?
Download Anaconda
Visit the link https://www.anaconda.com/download
Select Window / Mac
Download the current python version
Open downloaded file
Click continue
Click install for me only
You get notification ‘The installation was completed successfully’
Click close
How to write and run a code on Jupyter Notebook?
Open anaconda prompt
Select desired folder from the given list of directories
Click new
Click python 3
Write your code inside the cells
Example: Python Code to print Hello World
print("Hello World")
Rename file name
Click file
Click save as
Click file path (This is optional)
Click save
Click ‘Shift + Enter’ to run your code
Finally you will get an output ‘Hello World’ on next line to your code Else you made a
mistake, so recheck it once again.
1 print("Hello World")
Hello World
Key Takeaways
Python is a high-level programming language known for its simplicity and readability.
We study Python because it is widely used, has a large community support, and offers
numerous applications in various domains.
Python was created by Guido van Rossum, and it was first released in 1991.
Key features of Python include its easy-to-learn syntax, open source, extensive standard
library, portable and platform independent.
Python has a wide range of applications, including web & App development, data analysis,
machine learning, scientific computing, automation, and scripting, among others.
Jupyter Notebook is a popular IDE for data science and machine learning tasks.
// END OF CHAPTER TWO
Click here for Chapter Three