INTRODUCTION TO
PYTHON
Grade 10
Artificial Intelligence
Python – a mysterious name
• Python is a widely used general-purpose, high level programming language. It was initially designed
by Dutch programmer Guido van Rossum in 1991.
• The name Python comes from an old BBC television comedy series called Monty Python’s Flying
Circus. When Guido van Rossum was creating Python, he was also reading the scripts of Monty Python.
He thought the name Python was appropriately short and slightly mysterious.
Why should we learn Python?
▪ Python is a higher level programming language.
▪ Its syntax allows programmers to express concepts in fewer lines of code.
▪ Python is a programming language that lets you work quickly and integrate systems
more efficiently.
▪ One can plot figures using Python.
▪ One can perform symbolic mathematics easily using Python.
▪ It is available freely online.
Python versions
Python was first released on February 20, 1991 and later on developed by Python Software Foundation.
Major Python versions are – Python 1, Python 2 and Python 3.
• On 26th January 1994, Python 1.0 was released.
• On 16th October 2000, Python 2.0 was released with many new features.
• On 3rd December 2008, Python 3.0 was released with more testing and
includes new features.
Latest version - On 2nd October 2023, Python 3.12 was released.
To check your Python version
i) For Linux OS type python -V in the terminal window.
ii) For Windows and MacOS type import sys print(sys.version) in the interactive shell.
Searching for
Python
Downloading
Python
Python Interpreter
The program that translates Python instructions and then executes
them is the Python interpreter. When we write a Python program,
the program is executed by the Python interpreter. This interpreter
is written in the C language.
There are certain online interpreters like
https://ide.geeksforgeeks.org/,
http://ideone.com/ ,
http://codepad.org/
that can be used to start Python without installing an interpreter.
Python IDLE
Python interpreter is embedded in a number of larger programs that
make it particularly easy to develop Python programs. Such a
programming environment is IDLE
( Integrated Development and Learning Environment).
It is available freely online. For Windows machine IDLE
(Integrated Development and Learning Environment) is installed
when you install Python.
Running Python
There are two modes for using the Python interpreter:
1) Interactive Mode
2) Script Mode
Options for running the program:
• In Windows, you can display your folder contents, and double click on madlib.py
to start the program.
• In Linux or on a Mac you can open a terminal window, change into your python
directory, and enter the command python madlib.py
Interactive shell
IDLE shell
Running Python
1) in interactive mode:
>>> print("Hello Teachers")
Hello Teachers
>>> a=10
>>> print(a)
10
>>> x=10
>>> z=x+20
>>> z
30
Running Python
2) in script mode:
Programmers can store Python script source code in a file
with the .py extension, and use the interpreter to execute the
contents of the file.
For UNIX OS to run a script file MyFile.py you have to type:
python MyFile.py