PYTHON PROGRAMMING
The ultimate guide from a beginner to expert, all you need to know about python, tools, tricks, best practices, and advanced features
Table of Contents
Introduction
Congratulations on choosing to read Python Programming and thank you for doing so.
Welcome and much appreciation for downloading this Book. The Book will cover the entire Python programming language from an absolute beginner perspective. I placed more emphasis on the first three chapters to enable you to get furnished. Chapter 1 of the Book covers how to install and run Python IDE and your first Hello World Program. Chapter 2 will take you through writing variables from a practical approach. The seventh chapter focused on objects and classes. The eighth chapter addressed how to access and use time and date modules and classes in Python. Finally, the eleventh chapter discussed Machine Learning and Artificial Intelligence in detail as well as their applications in the real world.
The book Python Programming is written with the understanding that you are completely new to Python programming. For that reason, I took measures not to assume or leave out any crucial details. Unlike other books, I decided to split content meant for the first chapter into three chapters to slowly introduce you into Python programming. I explain systematically how to get started, keywords, statements, variables, data types, applications of Python programming in the real world such as Machine Learning, and type conversion among other topics of Python programming. After providing examples, the writer also provides follow-up exercises. The exercises are carefully selected and will not overwhelm you.
They are meant to help you systematically build confidence and skills in Python programming. Once you are done reading the book, you will be more than ready to handle any Python programming challenge.
The most exciting and crucial topics and subtopics of the book are:
Basics of Python Programming Language
Types of Variables
Methods/Functions in Python
Flow Control in Python
Data Processing, Analysis, and Visualization
Applications of Machine Learning
Inheritance and Polymorphism
Special Functions/Methods
Exception Handling
I am sure you will find the whole book interesting and easy to understand especially if you will read it systematically from chapter One to the last chapter.
There are many books about Python programming on the market, thank you again for selecting this one! Every effort was made to make sure you enjoy reading each chapter. It has a lot of useful information; kindly enjoy!
Chapter 1: Basics of Python Programming Language
Python is both procedural and object-oriented coding language. It has an easy syntax. Python programming language is cross-platform implying that it can be run on different Operating Systems environments such as Linux, Windows platform, Mac OS X platform, UNIX platform and can be ported to .NET and Java virtual machines. Python programming language is free and open source. While most recent versions of Mac and Linux have Python preinstalled, it is recommended that one installs and runs the current version.
Installation of Python
Most recent versions of Linux and Mac have Python already installed in them. However, you might need to install Python, and the following are the steps for installing Python in Windows, Mac OS X or Linux.
Installation of Python in Macintosh Operating System X
Visit Download Python page which is the credible site and click Download Python 3.7.2 (The version may differ from the one stated here).
When the download completes, click open the package and follow the instructions given. The installation should complete with The installation was successful prompt.
Now, visit Download Notepad++ and download the text editor and install it by opening the package and following the message prompts. The Notepad++ text editor is free and suited to help write source code (raw text programming words).
Installation of Python in Linux Operating System
If your distribution didn't come with Python, or came with an earlier version, install Python before installing pip and the AWS CLI.
To install Python 3 on Linux
a) See if Python is already installed.
$ python --version
or
$ python3 --version
If your Linux distribution came with Python, you might need to install the Python developer package to get the headers and libraries required to compile extensions, and install the AWS CLI. Use your package manager to install the developer package (typically named python-dev or python-devel ).
b) If Python 2.7 or later is not installed, install Python with your distribution's package manager. The command and package name varies:
$ sudo apt-get install python3
$ sudo yum install python3
$ sudo zypper install python3
c) Open a command prompt or shell and run the following command to verify that Python installed correctly.
d) $ python3 --version
Python 3.6.8
It is now time to issue instructions to run the source code on your OS (Operating System)
Installation of Python in Windows Operating System
Visit Download Python site which is the recommended site and click Download Python 3.7.2 (The version may differ from the one stated here).
When your download completes, open the package by clicking and follow the guidelines given. The Python installation should complete with The installation was successful prompt.
When you install Python successfully, it also installs a program known as IDLE along with it. IDLE is a graphical user interface when working with Python. IDLE is an integrated development environment for Python programming language that has been bundled with the implementation of the language for a long time. It is usually packaged as an optional part with numerous Linux variants. It is entirely written in Tkinter GUI toolkit and Python.
Now, visit Download Notepad++ and download the text editor and install it by opening the package and following the message prompts. The Notepad++ text editor is free and suited to help write source code (raw text programming words).
Ways of Running Python
Now before we start running our first python program, it is important that we understand how we can run python programs. Running or executing or deploying or firing a program simply means that we are making the computer process instructions/lines of codes. For instance, if the lines of codes (program) require the computer to display some message, then it should. The following are the ways or mode of running python programs. The interpreter is a special program that is installed when installing the Python package and helps convert text code into a language that the computer understands and can act on it (executing).
i. Immediate Mode
It is a way of running python programs that are not written in a file. We get into the immediate mode by typing the word python in the command line and which will trigger the interpreter to switch to immediate mode. The immediate mode allows typing of expressions directly, and pressing enter generates the output. The sign below is the Python prompt: