Categories
Uncategorized

Syntax of Python program

Good evening everyone !

Let’s begin with the first module or topic of python:

PYTHON SYNTAX-

Syntax stands for a predefined format or a particular manner only in which you can write it, the same way!
Same way we call such syntaxes which particularly python follows are called Python Syntax.

Since python is different in several ways in compared to others languages, So it’s not necessary that syntax is going to be exactly same to same. It differs on it’s own way.

As compared to other languages let’s talk about some basic syntaxes of python.

For example: print(“Hello World”)

Output- Hello World


Yes , it’s just a single line of code .

Points to remember:


1. You don’t have to end the statement with semicolon(;)
Here the new line shows the end of statement.

2. You don’t have to declare the data type of the variable like other languages, python do it by it’s own.

3. One major important thing which you need to focus more on is Indentation , Indentation is the space in between the left most margin and the character/ code written.
For example:
while(i>0):
print(“Indentation is correct”)

The output will be – Indentation is correct for every value of i greater than 0.

Now for second case if you’ve written the same code in this manner:

Example:
while(i>0):
print(“Indentation is incorrect”)

It would have shown output as some indentation error has been occurred.
Now you know the reason because of the indentation.

Indentation is mainly the space as 2 tabs, or four spacebars pressed.
It places the code in the correct space or simple if you enter just after the colons in the first line it will lead to the next line with correct indented space.

4. Also while saving a python file you should save it with .py extension.

To get familiar with this code more 🙂

Keep learning!

Leave a comment

Design a site like this with WordPress.com
Get started