0% found this document useful (0 votes)
3 views

Python Essentials 1 - Module 1

Python, created by Guido van Rossum in 1989, is named after the TV show Monty Python and competes with Perl and Ruby. There are two main versions, Python 2 and Python 3, with CPython being the canonical implementation written in C. Python is an open-source, multi-platform language that is easy to learn, making it suitable for testers and developers alike.

Uploaded by

teo.lenarduzzi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Python Essentials 1 - Module 1

Python, created by Guido van Rossum in 1989, is named after the TV show Monty Python and competes with Perl and Ruby. There are two main versions, Python 2 and Python 3, with CPython being the canonical implementation written in C. Python is an open-source, multi-platform language that is easy to learn, making it suitable for testers and developers alike.

Uploaded by

teo.lenarduzzi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Python Essentials 1

1) Python history
Since Monty Python is considered one of the two fundamental nutrients to a
programmer (the other being pizza), Python's creator named the language in
honor of the TV show.
Created in 1989 by Guido van Rossum while he was looking for a "hobby"
programming project that would keep him occupied during the week around
Christmas
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.

2) Language
Alphabet : a set of symbols used to build words of a certain language (e.g., the
Latin alphabet for English, the Cyrillic alphabet for Russian, Kanji for Japanese,
and so on)
Lexique : (aka a dictionary) a set of words the language offers its users (e.g., the
word "computer" comes from the English language dictionary, while "cmoptrue"
doesn't; the word "chat" is present both in English and French dictionaries, but
their meanings are different)
Syntaxe : a set of rules (formal or informal, written or felt intuitively) used to
determine if a certain string of words forms a valid sentence (e.g., "I am a
python" is a syntactically correct phrase, while "I a python am" isn't)
Semantic : a set of rules determining if a certain phrase makes sense (e.g., "I
ate a doughnut" makes sense, but "A doughnut ate me" doesn't)
3) Transforming a program from a high-level programming language
into machine language
4) Python(s) ?
There are two main kinds of Python, called Python 2 and Python 3.
In addition to Python 2 and Python 3, there is more than one version of each.
There are the Pythons which are maintained by the people gathered around the
PSF (Python Software Foundation), a community that aims to develop, improve,
expand, and popularize Python and its environment. The PSF's president is Guido
von Rossum himself, and for this reason, these Pythons are called canonical.
They are also considered to be reference Pythons, as any other
implementation of the language should follow all standards established by the
PSF.
Guido van Rossum used the "C" programming language to implement the very
first version of his language and this decision is still in force. All Pythons coming
from the PSF are written in the "C" language.
This is why the PSF implementation is often referred to as CPython. This is the
most influential Python among all the Pythons in the world.
a) Cython : Automatically translate Python code (clean and clear) into “C”
Code (complicated and talkative)
b) Jython : “J” is for Java, Python written in Java instead of “C”, permitting
addind some Python flexibility for Javascript
c) Pypy : Python within Python in language RPython (restricted Python, the
source code is not run in the interpretation manner, but is instead
translated into the C programming language and then executed
separately.
d) MicroPython : efficient open source software implementation Python 3
optimized to run on microcontrollers

5) Starting Python needs

an editor which will support you in writing the code (it should have some special
features, not available in simple tools); this dedicated editor will give you more
than the standard OS equipment

a console in which you can launch your newly written code and stop it forcibly
when it gets out of control;

a tool named a debugger, able to launch your code step-by-step, which will allow
you to inspect it at each moment of execution.

6) Errors
The message (in red) shows (in the subsequent lines):
the traceback (which is the path that the code traverses through different parts
of the program – you can ignore it for now, as it is empty in such a simple code);
the location of the error (the name of the file containing the error, line number
and module name); note: the number may be misleading, as Python usually
shows the place where it first notices the effects of the error, not necessarily the
error itself;
the content of the erroneous line; note: IDLE’s editor window doesn’t show
line numbers, but it displays the current cursor location at the bottom-right
corner; use it to locate the erroneous line in a long source code;
the name of the error and a short explanation.
7) Summary
Machine code is a program written in machine language, which consists of
sequences of digital binary numbers: 0s and 1s.
Each language, be it machine language or natural language, consists of an
alphabet, a lexis, a syntax, and semantics.
A source file is a file that contains source code, that is, a program’s instructions.
The compiler translates (compiles) the source program (a set of high-level
language instructions) into machine code (a lower-level representation of the
source program). The sequence of 0s and 1s can be then executed by the
processor. The execution of the compiled code is usually faster than
interpretation.
A script is a set of high-level language commands in a file, structured to be
executed like a program. A Python script is therefore a file containing code
written in Python.
Python is a free and open-source programming language available to everyone. It
is a multi- and cross-platform language, which means a Python program written
on a Linux system will run on a Mac, and vice versa.
Because Python is relatively easy to learn and contains simple syntax, it is a good
choice for testers.
CPython is the original (traditional) Python language implementation written in
the C language, as opposed to other, non-default implementations, such as
Jython, implemented in the Java language, which came later. CPython is the
Python language implementation available for dowload, and the first to adopt
new features that come with all the subsequent Python versions.
A Python console is a command-line interpreter that allows you to execute
Python commands, instructions, and scripts line by line.

You might also like