0% found this document useful (0 votes)
15 views4 pages

Python Essentials Overview

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

Python Essentials Overview

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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.

Common questions

Powered by AI

Machine language consists of sequences of binary numbers (0s and 1s) that the computer's processor executes directly, whereas high-level languages like Python use syntax and semantics similar to human languages, requiring translation into machine code. Although Python's interpretive execution provides ease of use and flexibility, it generally results in slower execution speeds compared to directly compiled machine code, which executes faster due to reduced translation overhead .

Syntax in Python refers to the set of rules determining valid sentence structures, while semantics involves ensuring that these sentences make logical sense. Lexical correctness means the words used exist in the language's lexicon. A syntactically correct statement in Python might still be semantically incorrect if it doesn't logically convey the intended operation, such as incorrect use of operators or functions without meaning .

Canonical Python implementations, mainly CPython, follow standards established by the PSF, ensuring consistency and reliability in executing Python scripts. Non-canonical implementations like Jython or Pypy might offer unique optimizations or integrations but may deviate from standard behavior. Developers must consider compatibility, performance, and project requirements when choosing between them, balancing specialized benefits against ensuring conformity and broad library support .

Guido van Rossum created Python in 1989 as a 'hobby' programming project to keep himself occupied during the Christmas week. He named the language after the British comedy group Monty Python, reflecting a preference for a name that was short, unique, and slightly mysterious .

Python is a multi- and cross-platform language, meaning a program written in Python on one operating system, such as Linux, can run on another, like Mac, with little to no modification. This capability stems from Python being an interpreted language that does not compile to platform-specific machine code. This feature implies enhanced portability, making Python an ideal choice for projects requiring deployment across different environments .

The transition from Python 2 to Python 3 introduced changes that improved the language's capabilities and efficiency, yet affected backward compatibility. Python 3's stricter syntax and updated libraries require existing Python 2 codebases to undergo modifications. While tools exist to ease this transition, the process can be resource-intensive, impacting development timelines and requiring adaptative changes in project workflows .

MicroPython provides a lightweight, open-source implementation of Python 3 designed specifically for microcontrollers, offering advantages in power efficiency and small footprint compared to standard implementations. Unlike CPython, it is optimized for resource-constrained environments, allowing Python's simplicity and readability on platforms with limited memory and processing power .

The Python Software Foundation (PSF) is responsible for the development, improvement, expansion, and popularization of Python. It sets standards that other Python implementations follow, ensuring consistency across different variants. The PSF's influence is significant in the language's evolution, as it oversees the adoption of new features and maintains the language's core values and objectives .

Alternative Python implementations provide specialized features that benefit specific use cases. Jython, implemented in Java, allows for integration with Java applications, leveraging Java's libraries while deviating from C-based implementations. Pypy aims to improve execution speed through Just-In-Time compiling, though this may lead to compatibility issues with CPython. These implementations enhance Python's adaptability but may introduce trade-offs in compatibility and performance behavior .

Using a dedicated editor for Python provides features like syntax highlighting, code completion, and error detection, which are not available in simple text editors. Tools like debuggers enable programmers to execute code step-by-step, inspecting variables and execution flow, helping identify logic errors and improving code reliability and maintenance .

You might also like