Python Programming - Installing and Starting the Interpreter
Installing Python
Download the python from python.org for specific platform and install. If required add to the search path.
In windows, to add python to path, open the command prompt and use
>set path = %path%;C:\pythonxx
assuming python is installed on C drive. Replace the xx to the respective version number.
Starting Python
Python can be started in the following ways,
1. Immediate Mode
In command prompt or terminal, type python, which will bring the python shell prompt.
>python
>>>
You can straight away start using the interpreter as calculator or with small commands.
For example,
>>> 1+1
2
>>>print("Hello, World!")
Hello, World
you can exit from the python shell prompt using quit() or exit()
>>>quit()
or
>>>exit()
2. Script Mode
In this mode the Python code/script will be written in a file and saved as filename.py for example. And can be run from the command prompt
>>>python filename.py
Python also comes with a IDLE, which contains both shell and script mode. In script mode the code can be saved as file and run the code using shortcut key F5. The code will be executed on the python shell inside the IDLE.
Comments
Post a Comment