Getting Started With Python
11 March, 2022
11
11
1
Contributors
Introduction to Python
Python is a simple, well-structured, easy-to-read syntax interpreted high-level programming language.
Programming Language:- A human readable language used to give instructions to computers, written in various ways and compiled by using a compiler and then converted to machine-understandable language to process the desired work.
There are many programming languages in the world. But among all of them Python is the most popular programming language.
Why Python?
- Easy to Read and Debug
- Helps to write Clean Code
- Easy Syntax
- Many things can be done by writing fewer lines of code, whereas, in other language you have to write more lines of code to do the same task.
Where Python is used?
It is used in the following cases -
- Making Games
- Making Web Apps
- Artificial Intelligence
- Data Science, and many more.
Setting Up Python In Your Computer
You can download python from here. Then install it as you install a software on your computer.
Python Current Versions
Every day technology is evolving and software and programming languages are also upgrading everyday and new versions are coming up. Basically, Python has two versions now - Python2 and Python3. If you've already installed python on your computer and you're using Python2, then I would recommend you to upgrade it to Python3.
Checking your Current version of Python
- Type cmd in your search box of Windows.
- Open Command Prompt
- Type the following command and hit Enter.
You will see something like this -
Checking Python In Terminal After Installation
After you've installed Python on your system, now you have to check whether it is perfectly working on your system or not.
Follow these steps:-
- Open your terminal(Command Prompt)
- Type python and hit Enter.
It will come up like this - - Type the following and hit Enter.
- The output should appear like this -
- Now, this proves that Python is working perfectly on your system.
- Now type exit() and hit Enter and then close the terminal.
Congratulations. š You have done your first Python program via the terminal. š
Use of Python files
It's not always a good practice to write your code in the terminal and run it to get the output. Also, it doesn't save your in the terminal. So, we all create a Python file to save our code on our machine and we use a code editor or IDE to compile our Python file having the source code and get the output.
You can use any code editor or IDE you like based on your requirements. You can use PyCharm. I personally love to use Visual Studio Code and it's beginner friendly too.
Some IDE's and Code Editors for Python
- Visual Studio Code. -> [Code Editor]
- PyCharm. -> [IDE]
- Sublime Text. -> [Code Editor]
- Atom. -> [Code Editor]
- Jupyter Notebook
- GNU Emacs. -> [Code Editor]
Setting Up Visual Studio Code for Python
- Download and install Visual Studio Code from the link given above. It's free of cost.
- Open it and then go to the Extension Tab.
- Type python in the search bar and click on the first one powered by Microsoft.
- Install it and reload the VS code after installing the extension. Since, I've already installed, it's showing it me the two buttons Disable and Uninstall. But when you'll install it for the first time, there will only one single Install button there for you. After installation, it should show like the above image.
š Note that, it's an extension so no options like Next Next buttons in a dialog box will appear before you. It will get install automatically as you click on the Install button.
Writing Program in Visual Studio Code
- Create a python file in the sidebar with add.py and hit enter.
- Select the interpreter for Python by using the shortcut Ctrl+Shift+P.
- Write the following code in your file.
- Save your file and run it using the Run Code button located on the top right corner of VS Code.
- The output should come like this:-
Congratulations. š You have learnt how to add two numbers and print the value. š
Explaining the Code
Here, a, b and s are variables. We have assigned a value 5 to a and 7 to b. Then we have added the two numbers 5 and 7 and stored it into s variable. Then we're printing the value of sum of two variables a and b. Here, print() is an in-built function used to print any values or names as Output.
For now, you understand it as like you have 3 bowls with you and the first 2 bowls contain some items in it and we're mixing the items together in the 3rd bowl and displaying the mixture.
We'll cover variables and data types and all other things in detail in our upcoming articles.
You can also watch this video for clarity.
Hope this helps you. Thank you for reading, and let's connect!
Thank you for reading my blog. Feel free to subscribe to my YouTube Channel and connect on LinkedIn or Twitter. Also, feel free to support my work.š
python
#python
python-basics