Tutorial: Python program for beginners
This blog post will guide you to write your first computer program in Python programming language and execute it. When you’ve finished this, you will leave with a sense of joy in having written your own computer software!
What is a programming language? What is coding?
A programming language is the set of instructions through which humans interact with computers. Coding or the code is similar to a written paragraph containing instructions of tasks to be executed by the computer. Writing a code in a particular programming language (there are a lot of them out there – C, C++, Python, etc.) results in a computer program.
Without computer programs, computers will not be able to do anything. With a computer program, you can get computers to draw shapes, play videos, create graphics, and what not!
What is Python?
Python is one of the (and arguably the most popular) programming languages available nowadays. It is a simple, easy, and very versatile programming language allowing many programming styles and concepts to be coded. It was created by Guido Van Rossum in 1991 and is widely used in hobby projects such as home automation, and large companies such as Google and Netflix.
How to setup python in your system?
Python is available for all the operating systems (Windows, Mac, and Linux). You can download the latest version of python (python 3.9.0.) software from https://www.python.org/downloads/
There is an online community forum to help python users. You can access it here – https://www.python.org/community/forums/
We will be using the Linux operating system in this blog post.
How to install python in Linux:
You can also install python directly through the terminal in Linux operating system. Follow the steps below to do that.
- Open the terminal in Ubuntu using Ctrl+Alt+T
- Update and refresh repository lists using the command sudo apt-get update
- Install python using the command sudo apt-get install python
- The terminal will ask the admin user password to install python software. Enter the password and hit the Enter button
- It will prompt a confirmation to continue the installation process. Type Y and hit Enter
- Once the installation is done, check the version of python to verify the installation process using the command python –version
It is a tradition for your very first program to display the text “Hello, World!” on the screen. There is nothing easier in computer programming. Follow the steps below and keep trying until you succeed.
- Create an empty text document and type the displayed code in it. Save the file with the name helloworld.py on the desktop
print() function is used to display the output on the screen using Python.
File Name: helloworld.py
- Execute the python file with the following command.
File Name: python helloworld.py
Note: Check the file location and move to the directory where the helloworld.py file is present using the cd command and then execute the python program file.
We can also execute Python codes on the terminal directly. See the following example
- Open terminal and Type: python3
- Then start executing python statements like
Congratulations! You have successfully written your first computer program using the Python programming language.
Credit: Boddu Lingaiah