Thonny Python 2


Python Implementation started on December, 1989 and reached version 1.0 in January 1994. Python 2.0 was released on October 16, 2000, with many major new features, including a cycle-detecting garbage collector for memory management and support for Unicode. Online Python Compiler, Online Python Editor, Online Python IDE, Python Coding Online, Practice Python Online, Execute Python Online, Compile Python Online, Run Python Online, Online Python Interpreter, Execute Python Online (Python v2.7.13).

Thonny Python 2

2.2. Using Thonny¶

There are two ways to use Thonny: shell mode and programmode. In shell mode, you type Python expressions into the Python shell,and the interpreter immediately shows the result. The example below shows the Python shell at work.

The >>> is called the Python prompt. The interpreter uses the prompt toindicate that it is ready for instructions. We typed 2+3, then pressed Enter. Theinterpreter evaluated our expression and replied 5. On the next lineit gave a new prompt indicating that it is ready for more input.

Working directly in the interpreter is convenient for testing short bits ofcode because you get immediate feedback. Think of it as scratch paper used tohelp you work out problems.

Alternatively, you can write an entire program by placing lines of Python instructionsin a file and then use the interpreter toexecute the contents of the file as a whole. Such a file is often referred to as source code. Forexample, we used Thonny to create a source code file named firstprogram.py withthe following contents:

By convention, files that contain Python programs have names that end with.py . Thonny will save your files with a .py extension automatically, and you should be able to open them in Thonny by double clicking them in File Explorer (or Finder).

Thonny Python 2


Notice that when we were using the shell, we didn’t have to worry about using print() to see the value of a statement. The shell does that automatically. However, if we are using the code editor, we need to call print() any time we want to see output.

Thonny Python Part 2


Check your understanding

Thonny Python 2 Programming

    python-variables1: Source code is another name for:
  • the instructions in a program, stored in a file.
  • The file that contains the instructions written in the high level language is called the source code file.
  • the language that you are programming in (e.g., Python).
  • This language is simply called the programming language, or simply the language.
  • the environment/tool in which you are programming.
  • The environment may be called the IDE, or integrated development environment, though not always.
  • the number (or 'code') that you must input at the top of each program to tell the computer how to execute your program.
  • There is no such number that you must type in at the start of your program.