<<< Prev

Next >>>

Python Syntax

  • For that how to execute python that we see first.
    • Interactive Mode:
      • Python provide interactive shell to run the code very fast and efficient way.
      • Open the shell you have to go python installation directory and write the Python in your cmd.


  • Now execute the python program.


  • Script Mode: You can also use a notepad or Notepad++ to run python program but you have to save this file with .py extension.

  • Using IDE:  We can run our code using GUI and best thing is python will provide the own IDE to build small small program.

Python Variable:

Variable is to use for refer a memory location and we also known as identifier and used to store the value.

In python, we don’t need to declare any variable data type like like java or c it will automatically understand and get variable type.

Python Identifier:

  • Python identifier name is used for the identify a variable, method, class, module or other object.
  • First latter of identifier must be alphabet else underscore(__)
  • Python identifier, all the character except first latter may be alphabet of lower-case , underscore , upper-case and number(Digit).
  • Identifier will not contain any special type character.
  • Example c123, c_Ey123 etc…
  • Invalid identifier @an, 1Z, n 5 etc…

 Python Keywords

Keywords are the reserved words in Python. We cannot use a keyword as variable name, function name or any other identifier.

  We cannot use a keyword as&nbspvariable name, function name or any other identifier. They are used to define the syntax and structure of the Python language.

In Python, keywords are case sensitive.

All the keywords except True, False and None are in lowercase and they must be written as it is.  The list of all the keywords are given below.

Multiple Assignment:

In python, we can assign same/single  value to different variable.

>>> a=b=c=12
>>> print(a)
>>> print(b)
>>> print(c)


Now assign multiple value to multiple variable.

Ex : 
>>> a,b,c =10,5,6
>>> print(a)
>>> print(b)
>>> print(c)