5 Steps for Getting Started with Python 3 | Beginners Guide
Python is one of the most popular computer languages. And if you are a beginner, we have listed Python among the 5 best programming language for beginners. I must say, this is the right time for you to get started with Python.
Whether you want to write a script for automation or manipulation data for analytics or building websites; Python is one of the best choices.
Looking at the power of Python language of doing so many things, Python is widely accepted in the software industry in a wide range of projects.
Let’s see the best way to learn Python…
Note: There are two major Python versions- Python 2 and Python 3. Going forward, you should focus on Python 3 rather than Python 2.
Getting Started with Python
I am glad for your choice of learning Python. Myself being Python developer, I am going to give you steps to kick start learning Python.
1. Downloading and Installing Python
There are two versions of Python: Python 2.x and Python 3.x. Python 3.x is released long back but many still use Python 2.x. Python 2.x is very much comfortable and stable.
The code running on Python 2 is not necessary to work on Python 3. So it is difficult to move from Python 2 to Python 3. This is the main reason as many companies (even Google) still uses Python 2 version.
For more detail, you can read the difference between Python 2 and Python 3.
As you are a beginner, I would suggest you install the latest Python 3 version.
Download the Python from its official website.
Once the download completes, install it.
2. Setting Environment Variable in Python
- After installing Python, you can check the installed Python path (By default,
- Copy this Path.
- Click on
Startthen right click on
- Click on
Advance System Setting.
- Click on
System Variablessearch for variable
Path. And click on
- Append ‘; ‘ at the end of the Variable value, followed by Python Path.
Now, it’s time to verify Python installation and configuration.
3. Check the Python Installation
Windows+R and then type
python. Or you can open a command prompt and the execute command
Open a terminal and execute the command
If the Python is installed properly, it will open a Python console. And then just test your first python code.
print("Hello, World!") #Hello, World!
You can try some basic arithmetic calculations using python commands.
ani:~$ python Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) Type "help", "copyright", "credits" or "license" for more information. >>> 3 + 6 9 >>> 56 - 2 54 >>> 56 * 7 392 >>> 55 / 8 6 >>> 67 % 9 4 >>> >>> exit()
exit() is a command to terminate the Python console.
This is the basic calculator you can use if you ever been into accounting bills. I prefer it to the calculator software that comes with the system. 😛
Now we are just running Python commands. Let’s see how to write and run the Python program.
To write a python program you need an editor.
4. Installing Editor for Writing Python Program
If you are using Windows OS, you might have notepad installed on your system. Initially, you can use that. Notepad only shows basic text and doesn’t highlight syntax. But it is ok, initially.
To highlight syntax you can install Notepad++. It makes your programming easy. It is also open-source.
If you want to start building the project, I would recommend using a Sublime editor.
Later you can move to the PyCharm. It is a dedicated IDE for Python that needs to be configured before using it. I have already written a complete tutorial for PyCharm setup.
vim is the best editor you should use. I use it personally and I don’t want to move to any other editor. It is the standard editor for all the programming development.
Without getting much confusion; For beginners, I would recommend using Notepad++ on Windows and Vim on Linux based systems.
All the setup is ready for getting started with Python. Let’s start savoring Python skills.
5. Running Python Program
Open the editor and write a hello world program.
You don’t need to write any functions. You don’t need to write any classes or import any classes. This is just one line program that prints the output on the console.
Isn’t it simple?
Save the file with
.py extension (says
And run the Python program from the command prompt (terminal for Linux user).
Command to compile and to run the Python Program:
It will print “Hello, World” on the command prompt/ Python console.
That’s all. You are ready with the Python.
Sample Python Programs to Start With…
Here are some simple programs you can try to run.
Printing value of the variable:
a = 10 print("value of a is ", a) #value of a is 10
Find the sum of two numbers:
a = 10 b = 29 print("Sum = ", a+b) #Sum = 39
Comment in Python:
You can use the comment in Python code. A comment is followed by the character ‘#’.
a = 10 #a is first intger variable b = 29 #b is second integer variable #Calculating sum of two integer print("Sum = ", a+b) #Sum = 39
Exploring Python further…
In the above programs, we have hardcoded the values of a and b. You can take these values as user input. Read the next Python tutorial for taking user input.
Here is a sample program for the Swapping value of two variables in Python.
For your learning, you can try running Python programs we have shared in our Python tutorial.
For being a beginner, getting started with Python is not easy like all other programming languages. And I am sure you might have many doubts. Please write in a comment. I answer your question right back.