What is Python?
Python is a programming language developed by Guido Van Rossum. Python is most praised for its neat syntax and readable code, if you want to build a career in development field then Python is best for you to start with. It allows you to do everything with GUI development, web application, system administration tasks, financial calculation, data analysis, visualization and goes on.
Python is interpreted language, it is an interpreter program that parses python program line by line basis, as compared to compiled languages like C or C++, where compiler first compiles the program and then start running.
You must be thinking so what’s the difference?
Interpreted languages are bit slower as compared to compiled languages. You will surely get some performance benefits if you write your code in compiled languages like C or C++.
It is a daunting task for a beginner to write a code in such languages. You need to write most basic functions like calculate the length of the array, split the string etc. Sometimes you need to generate your own data structures to encapsulate data in advance programs. In C or C++ before you start solving your issues you must take care of all minor details.
This is where Python comes, you don’t need to define any data structure, or there is no need to define small utility functions because python has everything to get you started.
Additionally, there are hundreds of libraries of python available at https://pypi.python.org/ which you can use in your project.
Python is dynamically typed
You don’t require defining variable data type ahead of time, python automatically guesses the data type of the variable based on the type of value it contains.
myvar = “Hello World”
In the above statement “Hello World” is assigned to myvar , so the type of myvar is a string.
In python, you don’t require to end a statement with a semicolon ( ;).
Now suppose later in program we will assign myvar a value of 1 i.e
myvar = 1
Now myvar is of type int
Python is strongly typed
1 + “2”
Will be ’12’
Here 1 will be converted to a string and concatenated to “2”, which results in ’12’, which is a string. In Python automatic conversions are not allowed, so
1 + “2”
Will produce an error.
Write less code and do more
Python codes are generally 1/3 or 1/5 of the java code. It means we can write less code in Python to achieve the same target in Java.
In python to read a file you need just 2 lines:
with open(“myfile.txt”) as f:
How did I start programming in Python?
Any program you want to build such as GUI applications, create websites, scrape data from website, and analyze data, system administration task, game development and more.