Table of Contents
Wondering what in the world is programming?
Imagine you are playing with your dog, and you instruct him to bring the ball that you just threw. The dog will surely run towards the ball and fetch it for you. You might be thinking what this example has to do with programming?
So, let me tell you what you did was just instructed the dog to accomplish a task. That is you just “Programmed” your dog to do so.
Definition of Programming
Thus, with this knowledge let’s define programming,
Programming is writing a sequence of steps of instructions in order to execute or accomplish a task.
So what we did was we instructed the dog to perform the following steps,
- Run toward the ball
- Fetch the ball
- Bring the ball back
Thus we wrote a program for the dog.
Since computers are dumb, we humans have to instruct them to perform tasks. In the way we wrote a program for the dog, we write programs so that the computer can understand it and can execute the task. So, in simple terms this is Programming.
Computers cannot understand the languages we speak. We need a notion through which we can communicate with them. The languages that help us to communicate with computers and allow us to write programs are called Programming Languages.
What is Python?
Python is a high-level programming language that uses instructions to teach the computer how to perform a task. Python is an easy-to-learn, powerful programming language. A language that is closer to a human language (like English) is known as a high-level language.
Python provides an easy approach to object-oriented programming. Object-oriented is an approach used to write programs. Python is a free and open-source language. That is, you can read, modify and distribute the source code of Python scripts. It was developed by Guido van Rossum and was released in 1991.
Python 2 Vs Python 3
Differences between Python 2 and Python 3
There are two versions of Python available, Namely: Python 2.X and Python 3.X. Don’t worry! In 2023, you don’t need to learn Python 2. Just learn Python 3 and you are ready to survive in the world. But if you already know Python 2, there are a few differences between both versions that you need to know.
The first major difference between Py2 and Py3 is: Python 2 is more structured programming language whereas, Python 3 is more Object-oriented language.
Another difference between Py2 and Py3 is in “print” function that is used to print data onto the console screen. In Python 2 print function does not require parentheses (round brackets)
print “Hello Python!”. Whereas in Python 3, the print function compulsorily needs parentheses in which the data that is to be printed is passed. For example:
Python 2 and Python 3 have some differences when dividing two numbers, If we divide 5/2 in Python 2, the output will be 2 since the numbers are of integer type. If you are not familiar with what an integer is, don’t worry we will discuss it further, just understand that Integers are some real numbers. Whereas in Python 3, the output will be 2.5.
Another difference that we can point out is in taking input from the user.
In Python 2 if we want to take input in words from the user,
raw_input() method is used whereas if we want any other type of input,
input() method is used.
Whereas in Python 3, there is no method called raw_input(), only
input() method is used to take input from the user.
Also, there is the addition of “as” keyword in Python 3. There are a few more differences that you can surely explore!
Why Learn Python?
Where is Python used?
Python is utilized in many domains. Python is everywhere. We may not even realize how widespread it is. But what exactly is Python used for? What areas of technology or business does Python benefit the most? Let’s see some specific scenarios where Python is used!
Python is used:
- In game and app development.
- To create web applications.
- In Artificial Intelligence, Machine learning, and Data science.
- To create desktop applications.
- In Embedded Systems, the Internet of things, and more.
Thus we have seen that Python is used in almost everything. So rather than learning many programming languages, Master one language i.e Python!!
How does Python work?
- First, we write instructions in English-based Python language.
- Python is an interpreted language, so there is no need to compile them.
Python programs run directly through a source code. The source code is converted into an intermediate bytecode and then into the native language of the computer by the Python interpreter. The code is executed and the output is presented.