An Overview Of Python

In this era of the diversity in latest technology and the ability to learn and be equipped in languages is the most challenging and interesting thing for a developer or a geek you can say. Me being a .Net developer found it interesting personally to get started with the Python, an open source programming language using the Microsoft IDE, the latest one i.e. Visual Studio Code. There are many reasons to choose & learn Python as my choice out of the box , now since Machine learning is the new latest!! :D Python is the best programming language and light weight to be used. I again say it is my personal choice to choose Python. :P Much of talks now, lets get started with what Python is actually and some facts about Python.

Introduction

In this era of diversity in the latest technology, the ability to learn and be equipped in languages is the most challenging and interesting thing for a developer or a geek you can say. Me being a .NET developer, I found it interesting personally to get started with Python, an open source programming language using the Microsoft IDE, the latest one, i.e., Visual Studio Code. There are many reasons to choose & learn Python as my choice out of the box now since Machine Learning is the newest! Python is the best programming language and lightweight to use. I again say it is my personal choice to choose Python. Enough talk, let's get started with what Python actually is and some facts about Python.

Python??

It's an interpreted language which obviously follows object-oriented principles. Now, a lot of technical terms are being used. As of now, I know C# (Programming Language) is interpreted into bytecode and then is compiled by the Common Language Runtime whereas Python is a completely interpreted language, which means it is executed directly at the runtime unlike the compiled language, which first gets compiled into the assembly language which any CPU can understand. Python is considered as one of the best Rapid Application Development programming languages. It is easy so far for me to learn Python though it is just the beginning. Its semantics are diversified, that is, it makes easy as well as strict for the developers to follow the coding convention. The indentation is a part of its syntax and the semantics are modular which makes it rather more convenient for the developers to maintain the code.

Setting up Python

Here, I would be sharing the process to set up Python on Windows. First of all, check if Python is pre-installed on your system. To check that, open Command Prompt and type python. If the output is not desirable i.e. 'python' is not recognized, then it is not installed to that path.

To download and install Python, click on the below link and download: Download Python for windows. Now, once downloaded, install the Python file with .msi extension in a path and navigate to the same path in command prompt and type python there. This output would show Python with the version installed and we are ready to write our first Hello World program and follow the tradition.
 
But before that, one of the important things to be done is setting up the environment variables or the system path. This is mainly required in UNIX and Windows because the OS searches for the executable in the specified path in the environment variables set. In Macintosh, the path is handled by the installer. Thus, the below images would guide to set the variables.
Python

Now,  we are all set for Python to run on Windows Command Prompt with the first "Hello World" program.

Python

To develop applications using Python, we would surely need Python IDE. There would be many in the market, but yes, after being obsessed with the Microsoft products, I prefer to use the open source IDE by Microsoft, Visual Studio Code.

Get started with Visual Studio Code

 

To start with after setting up Python on Windows, we need to install the Python extension for Visual Studio Code. Once the extension of Python for the Visual Studio code is installed, open Visual Studio Code and go to Files->Preferences->Settings. Once navigated, the User Settings window pops up. Once you see this window,

Python

Search for the "python.pythonPath". There would be Default Settings for the variable, now change the path to the installed folder path on your system.

 

  1.  //Default settings  
  2. // Path to Python, you can use a custom version of Python by modifying this setting to include the  
  3. full path.  
  4. "python.pythonPath""python"  

Path is changed under User Settings too.

  1. //User Settings  
  2. {  
  3.    "python.pythonPath""C:\\Python27\\python.exe"  
  4. }  

 

Python

Now, we are all set to run any application on the Visual Studio Code in Python. In the IDE terminal below, type python; the output is as below.

 Python

When we navigate to the Extensions, we can see Python is enabled, with the Linking, Debugging extension. These are used for IntelliSense, the reason I love Visual Studio. Also, there are a few modules/packages which are kind of third-party but can be used as these are all open source. Just like in .NET, we have Nuget Package Manager. So in the terminal itself of the IDE, we can install any modules of Python like with the below command.

 

  1. > python -m pip install httppie  

The above was one of the examples. The detailed discussion is out of this article's scope. We will discuss in upcoming articles of this series. Now, let's go ahead without wasting much time. Create a small program in Python and execute that to see the output.

  1. class Car(object):  
  2. """ 
  3. blueprint for car 
  4. """  
  5. def __init__(self, model, color, company, speed_limit):  
  6. self.color = color  
  7. self.company = company  
  8. self.speed_limit = speed_limit  
  9. self.model = model  
  10. def start(self):  
  11. print("started")  
  12. maruti = Car("Ertiga","White","Maruti Suzuki",140)  
  13. maruti.start()  

This is a simple program where we have a class named Car with a method as Start that prints "started". We will learn more about the properties and constructor in the next article. Maruti is the object instantiated and then the method start() is invoked through it. Thus, debugging this will give the output "started".

Conclusion

Next, we will discuss the details and basics of Python in the upcoming articles of this series.