Mastering Python Fundamental in 3 days | Day 1 |Python Installation And First Program With Python
Why should python why not other programming languages? Python is an interpreter language so it will feel “a little” slow compared to other languages that use compilers such as c and c++, but this is relative because it depends on the size of the program is made. Before using python, first, install python on your computer. Windows users can directly download the file at https://www.python.org/downloads/.
Now I will show you how to install python on Linux for this time I use ubuntu 20.04 :
Installing python on ubuntu is very easy, it only takes a few minutes then python will be installed on your computer.
- First, start by updating the package index and installing the prerequisites
sudo apt updatesudo apt install software-properties-common
2. Next add dead snakes PPA to the source list
sudo add-apt-repository ppa:deadsnakes/ppa
3. You will be asked to press “Enter” to continue
Press [ENTER] to continue or Ctrl-c to cancel adding it.
4. Once the repository is enabled, install python with the command
sudo apt install python3.9
5. Check python installation with command
python3.9 —- version
First Program With Python
Python is a simple language and has an easy syntax. When we first learn a programming language, we are definitely told to display the program “Hello World !” and in python, it can be done simply by writing the command print( “Hello World ! “ ). In this first program, I will demonstrate the use of python in a program to add two numbers.
In this program, we request the input number from the user, and we store it in the variables bil1 and bil2, respectively.
We use the input() function to request input. The input() function returns a string, so we must first convert it using the float() function. We store the amount in the amount variable.
Finally, we display the amount by using the print() function.