Python1
Python1
Chapter 1
Introduction
With this textbook you will learn basic Python programming. The textbook
contains lots of examples and self-paced tasks that the users should go through
and solve in their own pace.
You will _nd additional resources on my blog/web site [1].
https://www.halvorsen.blog
My Web Site about Python is:
https://www.halvorsen.blog/documents/programming/python/
See Figure 1.1
1.1 The New Age of Programming
The way we create software today has changed dramatically the last 30 years,
from the childhood of personal computers in the early 80s to today's powerful
devices such as Smartphones, Tablets and PCs.
The Internet has also changed the way we use devices and software. We still
have traditional desktop applications, but Web Sites, Web Applications and so-
called Apps for Smartphones, etc. are dominating the software market today.
We need to _nd and learn Programming Languages that are suitable for the
New Age of Programming.
We have today several thousand di_erent Programming Languages, so why
should we learn Python? I guess you will need to learn more than one Pro-
gramming Language to survive in today's software market. Python is easy to
learn, so it it a good starting point for new programmers.
Python is an interpreted, high-level, general-purpose programming language.
Created by Guido van Rossum and _rst released in 1991 [2].
11
Figure 1.1: Web Site - Python
Python is a fairly old Programming Language (1991) compared to many other
Programming Languages like C# (2000), Swift (2014), Java (1995), PHP (1995).
Python has during the last 10 years become more and more popular. Today,
Python has become one of the most popular Programming Languages.
There are many di_erent rankings regarding which programming language which
is most popular. In most of these ranking, Python is in top 10.
One of these rankings is the IEEE Spectrum's ranking of the top programming
languages [3].
From this ranking we see that Python is the most popular Programming Lan-
guage in 2018. See Figure 1.2
As we see in Figure 1.2 they categorize the di_erent Programming Languages
into the following categories:
_ Web
12
Figure 1.2: The Most Popular Programming Languages
_ Mobile
_ Enterprise
_ Embedded
According to Figure 1.2 we see that Python can be used to program Web Ap-
plications, Enterprise Applications and Embedded Applications.
So far Python is not used or not optimized for creating Mobile Applications. We
have today 2 major Mobile platforms; iOS Applications are mainly programmed
with the Swift Programming language, while Android Applications are mainly
programmed with either Java or Kotlin.
Another survey is the "Stack Overow Developer Survey 2018" [4]. See Figure
1.3.
As we can see from [5] and Figure 1.4, Python becomes more and more popular
year by year.
Based on Figure 1.4, the source [5] try to predict the future of Python, see
Figure 1.5.
Based on the surveys and statistics mention above, obviously Python is a pro-
gramming language that you should learn.
Lets summarize:
_ Python is fun to learn and use and it is also named after the British
comedy group called Monty Python.
_ Python has a simple and exible code structure and the code is easy to
read.
13
Figure 1.3: The Top Programming Languages - Stack Overow Survey
_ Python is highly extendable due to its high number of free available
Python Packaged and Libraries
_ Python can be used on all platforms (Windows, macOS and Linux).
_ Python is multi-purpose and can be used for to programWeb Applications,
Enterprise Applications and Embedded Applications, and within Data
Science and Engineering Applications.
_ The popularity of Python is growing fast.
_ Python is open source and free to use
_ The growing Python community makes it easy to _nd documentation,
code examples and get help when needed
In general, Python is a multipurpose programming language that can be used
in many situations. But there is not one programming language which is best
in all kind of situations, so it is important that you know about and have skills
in di_erent languages.
My list of recommendations (one of many):
_ Visual Studio and C
_ LabVIEW - a graphical programming language well suited for hardware
integration, taking measurements and data logging
_ MATLAB - Numerical calculations and Scienti_c computing
_ Python - Numerical calculations, and Scienti_c computing, etc.
_ Web Programming, such as HTML, CSS, JavaScript and a Server-side
framework/programming language like PHP, ASP.NET (C or VB.NET),
Django (Python based)
14
Figure 1.4: The Incredible Growth of Python
_ Databases (such as SQL Server and MySQL) and using the Structured
Query Language (SQL) or the upcoming NoSQL databases
_ App Development for the 2 main platforms iOS (XCode using the Swift
Programming Language) and Android (Android Studio using the Java
Programming Language or Kotlin Programming language)
If you