In this article, we will learn different ways to start Python and we make our first full-functioning Python Program that will show the result on the output screen.
Python includes many features from C, Perl, and Java but not the same as these languages. It is always a good choice to install the most current version of Python Programming Langage which you can download and install easily.
Before moving forward for making our first Python Program we need to start/locate our Interpreter.
Starting the Interpreter
When you have installed your Python successfully on your machine now it’s time to locate Python Interpreter. The location address /usr/local/bin/pythonX.X is default location in Linux/Unix OS.
In Windows OS the default address is C:\PythonXX or in some cases location might be different and remember by “X” means the current version of Python Programming Language.
Before doing anything else first thing we have to do is to start the Python interpreter so it makes possible for our code to run and show the output to the screen.
To access the Python simply open up your command prompt and type “python” as shown in the image below but make sure you have installed the Python on your computer successfully.
After setting up our Interpreter we can discuss the ways to start the Python Language.
In immediate mode we run code without making any file separately so, we do direct coding to show the output to the screen. To do so simply open the command line and type “python” it will invoke the python’s interpreter. We can directly type our Python piece of code and press enter to get the output to the screen.
does the above symbol appears if yes then it is the sign that the Python interpreter is ready to use. Now for testing purpose type the following expression as
3 * 3 and press enter you should get the 9 in the output. You might say that it is our very basic calculator to use. To exit simply type exit() or quit() and that’s it.
2.Script Mode Programming
Generally, we mean something in writing by word script for example script for actors etc. In Python, we mean a piece of code written in a separate file which we access with Python IDLE(Integrated Development Environment).
I will do step by step process to make sure you will understand everything easily. So let’s begin.
First, open up your notepad and type whatever Python code you want to show up on the output screen.
Remember! You must write “print” before starting any expression to tell the interpreter that we want to show the output to the screen. And enclose your expression inside “middle brackets“. An illustration is presenting in the image below.
Now go to File > Save as > and write your file name and don’t forget to add the .py extension at the end of file name like HelloWorld.py. It is highly recommended to add the .py extension.
After this open your Python IDLE Go to File > Open and locate your saved notepad file wherever you save it. When file opened press shortcut key “F5” to run your code. In my case, the following result has shown to the screen.
3.Python Integrated Development Environment (IDE)
It is the most time saving and easiest way to write and work with Python Programming Langauge because an IDE comes with many great features like syntax highlighter, error identification, indentation, and file explorers, etc.
It provides an easy approach from an expert programmer to a beginner. You can also check out the Best IDE. By working with IDE you won’t have to open python shell or don’t have to start the command prompt to run your code an IDE handles all itself. You can customize IDE according to your needs.
First Program in Python Programming Language
In your script file or in your Python IDE no matter what IDE you installed type the code listed below as our first programming code:
print ("Python in Script Mode")
print (10 + 10)
print (10 * 10)
print (10 / 10)
print (10 - 10)
After running this code you should have the following output to the screen:
Python in Script Mode
Congratulations! You just have achieved an accomplishment of writing your first program in Python.