Python live interpreter:

In the previous article, we have seen, how to enter in python live interpreter. 

For exit from that, use 'exit()' command.



Syntax in python 

It does not have typical syntaxes like Java and C, but there are some rules of python language that you have to follow.

Indentation:

Indentation is used in python language everywhere. Indentation is nothing but they are spaces at the beginning of line code.

In python, Indentation or you must say proper indentation is very important because it indicates a block of code. Like in  C and Java, we have to use curly braces {} to separate that block of code. But in python, we have to use indentation.











Even if you don’t give proper indentation or if you give more and less indentation, it will give an error.

First case:




Second case:


Now, you have understood about this indentation. Let's move on the next topic.

Variables in python

Variables are the containers in which you can store data value. These are generally named for a memory place. In python, you don't need to declare the type of a variable, you can simply write the variable name and assign its value. For example,



It automatically identifies the type of variable. If you really want to know the type of python variable, you can use type() function together with print() function.

type() tells about the data type of a particular variable.




Terminal output


We will discuss more on type() function in future articles. 

Note: In python, to assign a string value in a variable you have to use either " " double quotes or ' ' single quotes.


Comments in python
Comments are the lines which are not executed at run time of code. These are used to explain the code, so everybody can understand the code and are used by the programmers to save the extra code inside the file if we don't want to use it but want to save it for later.

In python, to make a comment, we have to write a # at the beginning of the line.




If we declare a variable or any line of code after #, it will not be executed.



We will discuss more in the next articles.














 











Post a Comment

Previous Post Next Post