0% found this document useful (0 votes)
9 views10 pages

Chapter 3

Uploaded by

www.tooo18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views10 pages

Chapter 3

Uploaded by

www.tooo18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Kingdom of Saudi Arabia ‫المملكة العربية السعودية‬

Ministry of education ‫وزارة التعليم‬


Qassim University ‫جامعة القصيم‬
Applied College ‫الكلية التطبيقية‬

Chapter 3: Introduction to Python

1
ITBS103

Introduction to Python and Computer Programming

❑ Objectives
▪ Learn the essential fundamentals of computer
programming,
▪ Learn Python
▪ Learn Python programming environment.

▪ Covers everything you need to know to start


designing, writing, running, debugging, and
improving Python programs at the foundational level.

2
ITBS103

2
Section 1 – Introduction to Programming
Natural languages vs programming languages
❑ A language is a means (and a tool) for expressing and recording thoughts.
❑ Computers have their own language, too, called machine language, which is
very rudimentary.
❑ A computer, even the most technically sophisticated, is devoid of even a trace
of intelligence. You could say that it is like a well-trained dog - it responds only
to a predetermined set of known commands.
❑ The commands it recognizes are very simple. We can imagine that the
computer responds to orders like "take that number, divide by another and
save the result".
3
ITBS103

❑ A complete set of known commands is called an instruction list, sometimes


abbreviated to IL.
❑ Note: machine languages are developed by humans.
❑ No computer is currently capable of creating a new language. Machines have
many different languages, too.

4
ITBS103

4
Machine language vs. high-level language?
❑ The IL is, in fact, the alphabet of a machine language. This is the simplest and most
primary set of symbols we can use to give commands to a computer. It's the computer's
mother tongue.
❑ Unfortunately, this mother tongue is a far cry from a human mother tongue. We both (
computers and humans) need something else, a common language for computers and
humans, or a bridge between the two different worlds.
❑ We need a language in which humans can write their programs and a language that
computers may use to execute the programs, one that is far more complex than machine
language and yet far simpler than natural language.

5
ITBS103

❑ Such languages are often called high-level programming languages. They are at
least somewhat similar to natural ones in that they use symbols, words and
conventions readable to humans. These languages enable humans to express
commands to computers that are much more complex than those offered by ILs.
❑ A program written in a high-level programming language is called a source code
(in contrast to the machine code executed by computers). Similarly, the file
containing the source code is called the source file.

6
ITBS103

6
Section 1 – Introduction to Programming

❑ Compilation vs. Interpretation?


❑ Computer programming is the act of composing the selected programming language's elements in the order that will
cause the desired effect. The effect could be different in every specific case – it's up to the programmer's imagination,
knowledge and experience.
❑ Of course, such a composition has to be correct in many senses:
▪ alphabetically – a program needs to be written in a recognizable script, such as Roman, Cyrillic, etc.
▪ lexically – each programming language has its dictionary and you need to master it; thankfully, it's much simpler
and smaller than the dictionary of any natural language;
▪ syntactically – each language has its rules and they must be obeyed;
▪ semantically – the program has to make sense.
❑ Unfortunately, a programmer can also make mistakes with each of the above four senses. Each of them can cause the
program to become completely useless.

❑ Let's assume that you've successfully written a program. How do we persuade the computer to execute it? You have to
render your program into machine language. Luckily, the translation can be done by a computer itself, making the whole
process fast and efficient.

7
ITBS103

Section 1 – Introduction to Programming

❑ Compilation vs. Interpretation?


❑ There are two different ways of transforming a program from a high-level programming language into machine
language:

8
ITBS103

8
Section 1 – Introduction to Programming

❑ Compilation vs. Interpretation?


❑ The interpreter reads the source code in a way that is common in Western culture:
from top to bottom and from left to right. There are some exceptions - they'll be
covered later in the course.
❑ First of all, the interpreter checks if all subsequent lines are correct (using the four
aspects covered earlier).
❑ If the compiler finds an error, it finishes its work immediately. The only result in this
case is an error message.

❑ The interpreter will inform you where the error is located and what caused it. However, these messages may be
misleading, as the interpreter isn't able to follow your exact intentions, and may detect errors at some distance from
their real causes.
❑ If the line looks good, the interpreter tries to execute it (note: each line is usually executed separately)
❑ You may ask now: which is better? The "compiling" model or the "interpreting" model? There is no obvious answer. If
there had been, one of these models would have ceased to exist a long time ago. Both of them have their advantages
and their disadvantages.

9
ITBS103

Section 1 – Introduction to Programming

❑ What does this all mean for you?


❑ Python is an interpreted language. This means that it inherits all the described advantages and disadvantages. Of
course, it adds some of its unique features to both sets.
❑ If you want to program in Python, you'll need the Python interpreter. You won't be able to run your code without it.
Fortunately, Python is free. This is one of its most important advantages.
❑ Due to historical reasons, languages designed to be utilized in the interpretation manner are often called scripting
languages, while the source programs encoded using them are called scripts. Okay, let's meet Python.

10
ITBS103

10
Section 2 – Introduction to Python

❑ Python – a tool, not a reptile


❑ What is Python?
▪ Python is a widely-used, interpreted, object-oriented, and high-level programming language with dynamic
semantics, used for general-purpose programming.
▪ And while you may know the python as a large snake, the name of the Python programming language comes
from an old BBC television comedy sketch series called Monty Python's Flying Circus. Python's creator named
the language in honor of the TV show.

❑ Who created Python?


▪ One of the amazing features of Python is the fact that it is actually one person's work. Usually,
new programming languages are developed and published by large companies employing
due to copyright rules, Python is an exception.

▪ Python was created by Guido van Rossum, born in 1956 in Haarlem, the Netherlands. Of course, Guido van
Rossum did not develop and evolve all the Python components himself. The speed with which Python has spread
around the world is a result of the continuous work of thousands (very often anonymous) programmers, testers,
users (many of them aren't IT specialists) and enthusiasts.
11
ITBS103

11

Section 2 – Introduction to Python

❑ Python goals
In 1999, Guido van Rossum defined his goals for Python:

▪ an easy and intuitive language just as powerful as those of the major competitors;
▪ open source, so anyone can contribute to its development;
▪ code that is as understandable as plain English;
▪ suitable for everyday tasks, allowing for short development times.

❑ About 20 years later, it is clear that all these intentions have been fulfilled. Some sources say
that Python is the most popular programming language in the world, while others claim it's
the second or the third.
❑ Either way, it still occupies a high rank in the top ten of the PYPL PopularitY of Programming
Language and the TIOBE Programming Community Index.
❑ Python isn't a young language anymore. It is mature and trustworthy. It's not a one-hit
wonder. It's a bright star in the programming firmament, and time spent learning Python is a
very good investment.
12
ITBS103

12
Section 2 – Introduction to Python

❑ Why Python?
❑ it's easy to learn – the time needed to learn Python is shorter than for many other
languages; this means that it's possible to start the actual programming faster;
❑ it's easy to teach – the teaching workload is smaller than that needed by other
languages; this means that the teacher can put more emphasis on general (language-
independent) programming techniques, not wasting energy on exotic tricks, strange
exceptions and incomprehensible rules;
❑ it's easy to use for writing new software – it's often possible to write code faster when
using Python;
❑ it's easy to understand - it's also often easier to understand someone else's code faster
if it is written in Python;
❑ it's easy to obtain, install and deploy – Python is free, open and multiplatform; not all
languages can boast that.

13
ITBS103

13

Section 2 – Introduction to Python

❑ Python rivals?
❑ Python has two direct competitors, with comparable properties and predispositions. These are:

▪ Perl – a scripting language originally authored by Larry Wall;


▪ Ruby – a scripting language originally authored by Yukihiro Matsumoto.

❑ The former is more traditional and more conservative than Python, and resembles some of the old languages
derived from the classic C programming language.

❑ In contrast, the latter is more innovative and more full of fresh ideas than Python. Python itself lies somewhere
between these two creations.

❑ The Internet is full of forums with infinite discussions on the superiority of one of these three over the others,
should you wish to learn more about each of them.

14
ITBS103

14
Section 2 – Introduction to Python

❑ Where can we see Python in action?


❑ We see it every day and almost everywhere.
❑ It's used extensively to implement complex Internet services like search engines,
cloud storage and tools, social media and so on.
❑ Whenever you use any of these services, you are actually very close to Python,
although you wouldn't know it.
❑ Many developing tools are implemented in Python.
❑ More and more everyday-use applications are being written in Python. Lots of
scientists have abandoned expensive proprietary tools and switched to Python.
❑ Lots of IT project testers have started using Python to carry out repeatable test
procedures. The list is long.

15
ITBS103

15

Section 2 – Introduction to Python

❑ Why not Python?


❑ Despite Python's growing popularity, there are still some niches where Python is absent, or is rarely seen:

❑ low-level programming (sometimes called "close to metal" programming): if you want to implement an
extremely effective driver or graphical engine, you wouldn't use Python;

❑ applications for mobile devices: although this territory is still waiting to be conquered by Python, it will most
likely happen someday..

16
ITBS103

16
Section 2 – Introduction to Python

❑ There is more than one Python?


❑ Python 2 vs. Python 3
There are two main kinds of Python, called Python 2 and Python 3.

▪ Python 2 is an older version of the original Python. Its development has since been
intentionally stalled, although that doesn't mean that there are no updates to it. On
the contrary, the updates are issued on a regular basis, but they are not intended to
modify the language in any significant way. They rather fix any freshly discovered
bugs and security holes. Python 2's development path has reached a dead end
already, but Python 2 itself is still very much alive.

▪ Python 3 is the newer (or to be more precise, the current) version of the language.
It's going through its own evolutionary path, creating its own standards and habits.

17
ITBS103

17

Section 3 – Downloading and Installing Python

❑ How to download, install, and configure Python


❑ https://www.python.org/downloads/

18
ITBS103

18
Section 3 – Downloading and Installing Python

❑ Top Python IDEs & Code Editors: Download for Free & Paid

19
ITBS103

19

Section 3 – Downloading and Installing Python

❑ Download PyCharm (https://www.jetbrains.com/pycharm/download/#section=windows )

20
ITBS103

20

You might also like