How to start
Download and Install Python
Python works on Linux, Mac, Windows, and several other platforms. It comes preinstalled on macOS and on most Linux distributions. However, if you want to be up to date, then you probably need to download and install the latest version. You also have the choice of using different Python versions in different projects if you want to.
Installing Python From Binaries
Regardless of your operating system, you can download an appropriate version of Python from the official site. Go there and grab the appropriate 32-bit or 64-bit version for your operating system and processor.
Selecting and downloading a Python binary from the language's official site is often a good choice. However, there are some OS-specific alternatives:
- macOS : You have the option of installing Python from Homebrew.
- Linux : You can install several Python versions using your distribution's package manager.
- Windows : You can install Python from the Microsoft Store.
You can also use the Anaconda distribution to install Python along with a rich set of packages and libraries, or you can use Miniconda if you want to install only the packages you need.
Working in Interactive Mode
You can do a quick test to ensure Python is installed correctly. Fire up your terminal or command line and run the python3 command. That should open a Python interactive session, and your command prompt should look similar to this:
While you're here, you might as well run your first line of code:
>>> print("HELLO") HELLO >>>
That's it! You've just written your first Python program! When you're done, you can use exit() or quit() to leave the interactive session, or you can use the following key combinations:
- - macOS and Linux: Ctrl+D
- - Windows: Ctrl+D and then press Enter
Working Python in Windows
To work in interactive mode follow the process given below:
i. Click start button ⇨ All Programs ⇨ Python 3.7.4 ⇨ IDLE(Python GUI).
OR
Click Start button ⇨ All Programs ⇨ Python 3.7.4 ⇨ Python (command line).
Interactive commands and their output in Python Shell
Working in Script Mode (Python IDLE)
- Interactive mode does not save the commands entered by you in the form of a program.
- The output is sandwiched bet ween the command lines.
To save the program in a file you have to write your program in a script mode and save it in a file.
To create Module / script / Program File
- Click Start button ⇨ All Programs ⇨ Python 3.7.4 ⇨ IDLE
- Click File ⇨ New in IDLE Python Shell.
- In the New window that opens, type commands you want to save in the form of a program.
- Click File ⇨ Save and then save the file with an extension .py.
- To execute the program Click on Run ⇨ Run Module command. Or press F5 key.