working with python IDLE



Working with Python IDLE

Before you start working in Python, you need to install python on your computers. Multiple distributions of Python are available today. Anaconda Python Distribution is one such highly recommended distribution.
Many popular IDEs are also available like Spyder IDE, PyCharm IDE etc.
There is a default installation available from www.python.org which is CPython installation. CPython is the original Python implementation. It comes with Python IDLE and Pip.

When you download Python in our computer, then you may notice a new program on your machine called IDLE.
IDLE is Python’s Integrated Development and Learning Environment. Python IDLE makes it the perfect tool for a beginning programmer.

You can work in python in two ways:

  • Interactive Mode(Immediate Mode)
  • Script mode

Working in interactive Mode

In interactive mode there is a shell between the user and the operating system which reads a Python statement, evaluates the result of that statement, and then prints the result on the screen. Then, it loops back to read the next statement. With the Python interactive interpreter it is easy to check Python commands.

To work in interactive mode, follow the following steps:

1. Click start button->click all programs->click Python 3.8 -> click IDLE(Python 3.8)

Or

You can simply search IDLE in search box


And click click IDLE(Python 3.8)1. A python shell will be opened where you will see “>>>”. It is python prompt.
2. Now type any command like
>>>5+8
And press enter, you will see the result in next line
13



Working in script mode

If you need to write a long piece of Python code and save all the commands in the form of program file and want to see all output lines together then interactive mode is not recommended. Script mode is the way to go in such cases. In script mode, You write your code in a text file then save it with a .py extension which stands for "Python".

To work in scrip mode, follow the following steps:

1.Open IDLE as done in interactive mode.

2. Click File->New

3. A new window will be opened, type the commands or program in this window



Now to save the file, go to File->save and then choose the desired location and save the file.






Remember that “save as type ” should be python files. By doing this, our file will be saved with “.py” extension.
Now to run the file,
Go to Run->run module.
And you will see the output


Comments

Popular posts from this blog

escape sequence in python

Data Types in Python