Python Basics: The IDLE

Novak
3 min readMay 16, 2021

--

We are finally going to start our journey to Python’s Nest of Wonder. We will start by learning about the IDLE and Learn Python Basics.

The IDLE

Opening the IDLE

You run the interactive shell by launching IDLE, which you installed with Python in the introduction. On Windows, open the Start menu, select All Programs 4 Python 3.3, and then select IDLE (Python GUI). On OS X, select Applications 4 MacPython 3.3 4 IDLE. On Ubuntu, open a new Terminal window and enter idle3.

A window with the >>> prompt should appear.

That’s the interactive shell. Enter 2 + 2 at the prompt to have Python do some simple math.

IDLE doing simple math

In Python, the “2+2” is called an expression that is the most simple command or instruction in the language. Expressions always consist of values (2) and operators (+).

An Expression always evaluates. in “2+2” the expression is evaluated to 4 which is also an expression, but it always evaluates itself. For example, see this:-

4 always evaluates to 4

The following table shows the different types of operations.

The Basic Operator Table

The order of operations (also called precedence) of Python math operators is similar to that of mathematics. The ** operator is evaluated first; the *, /, //, and % operators are evaluated next, from left to right; and the + and — operators are evaluated last (also from left to right). You can use parentheses or () to override the usual precedence if you need to.

Play around with these operations to memorize their rules.

Errors

These rules for putting operators and values together to form expressions are a fundamental part of Python as a programming language, just like the grammar rules that help us communicate. Here’s an example:

This is a grammatically correct English sentence.

This grammatically is a sentence, not English correct a.

The second line is difficult to parse because it doesn’t follow the rules of English. Similarly, if you type in a bad Python instruction, Python won’t be able to understand it and will display a SyntaxError error message, as shown here:

Don’t worry about breaking your computer, the worst thing that could happen would be python giving a syntax error. These things happen all the time with professional developers. Programs will crash if they contain code the computer can’t understand, which will cause Python to show an error message. A crash just means the program stopped running unexpectedly. If you want to know more about an error message, you can search for the exact message text online to find out more about that specific error.

Here is a list of errors and their meanings.

This a small list, the number of errors and exceptions is huge. We will learn how to handle them later.

In the next post, we will go through the Data Types and Variables. Stick with us and learn Python thoroughly.

--

--

Novak

A hobbyist Pythonist who loves reading books and helping others