☰ Contents · Computing

Installing Python and the first program

Lessons 21 · 1 lessons · M. R. Fayziyeva, D. M. Sayfurov, N. S. Xaytullayeva. Informatics and Information Technologies, Grade 9. “Nashriyot uyi Tasvir”, Tashkent, 2020
21

Installing the Python programming language

Textbook: pp. 51–53
GoalKnows how to install Python safely from the official site, tells the interactive environment of IDLE from its programming (editor) environment, and writes and runs a first program with print().
New words
IDLE: the simple IDE that comes with Python; it has an interactive shell and a code editor · IDLEinteractive environment (shell): you type a command after >>> and see the result at once · interfaol muhitprogramming (editor) environment: a window where you write, save and run a whole program · dasturlash muhitiprint(): the operator (function) that shows data on the screen · print()
Explanation

Python is a free language that is easy to learn, has a large library, and is used for websites, apps, games and artificial intelligence. Download it only from the official site, the Downloads section of python.org: installers from unknown sites may contain harmful software, and copies obtained by piracy are illegal; an adult or the school IT person should help with the installation. Choose the installer for your operating system with the latest stable Python 3 version; on Windows tick “Add python.exe to PATH” in the installer window and then click “Install Now”. After installation you open IDLE from the start menu. In the interactive environment you type a command after the >>> sign and press Enter, and the result appears at once; it also works as a calculator. The programming environment is opened with File → New File, the code is written there, saved with File → Save and run with Run → Run Module (or F5); a program cannot be run without saving it. Note: on this site code with several lines is written on one line – the sign ⏎ marks the start of a new line (press Enter there in IDLE), and the blank space after ⏎ is the indentation at the start of the line (4 spaces per level); the ⏎ sign itself is not typed into the code.

Worked examples
In the interactive environment: after the >>> sign, if you type print("Salom!"), Salom! appears on the screen. If you type >>> 2 + 3 the result is 5 – the environment works like a calculator.
In the programming environment: File → New File, the code is print("Mening birinchi dasturim") – saved as birinchi.py; click Run → Run Module and Mening birinchi dasturim appears in the interactive window.
Class activity

“Safe installation list”: the group makes a list of “what not to do when downloading Python” (unknown site, unknown file, installing without an adult) and puts the right steps in order.

Practice
1
Where should Python be downloaded from?
2
Give in order the steps to run a first program in the programming environment.
3
Write a program that prints the line “Mening birinchi dasturim”.
4
Why should Python be downloaded only from the official site and not from unknown sites?