Python is a very powerful and popular programming language. It has a high-level data structures with an object-oriented programming approach with less syntactical constructions.
Python is one of the easy to learn compared to any other programming language. Its elegant and simple syntax is designed to be highly readable. It uses English keywords syntax frequently rather than punctuation as other programming languages do.
Python’s interpreter and the huge library are freely available in source or binary form at https://www.python.org. It is a great language for beginners level programmers because it’s very easy to learn.
Why Python is popular?
- Python is the second most liked and used programming language after JAVA which makes it truly popular.
- It can be used for server-side web development, software, and game development.
- It can be used to perform complex mathematics and handle huge data.
- It has a very simple syntax similar to the English language.
- Programmers can write the program in fewer lines compared to other programming languages.
- It uses the interpreter system which compiles the code as soon as it is written so prototyping can be very quick.
- Python uses a new line to complete the command rather than a semicolon (;) or parentheses as other programming languages do.
To download and install the Python click here. If you already have installed the Python then you can check it in your computer by the following command.
To create the Python file you need to save the file with .py extension. Let’s write a code to print a “Hello World” in python.
Following command is used to run a python file:
Indentation or spaces, are the most important things to keep in mind while you are writing a python program. Python uses indentation to identify the code block.
Python will give you error in the program if you skip adding indentation, you can add any number of spaces you like in the block of the code but there must be at least one. Let’s take a look at another python program to understand it better.
if 10 > 5: print("10 is greater than 5!") print("program end...")
In the above code, I have added two spaces in the print line (below the if condition), If I don’t add any space I will get an error OR also I will get an error if add more than two spaces in further lines of the code for eg:
print("program end...") must follow two spaces as the first line code after the condition block has used two spaces so all the following code must follow two line codes.
Note: you can use any number of space but the following code should follow the same number of spacing.
Checkout Java vs Python comparison here.