Python Variables , Python Identifiers and Python statements

Variables

  • Variables are reserved memory location in computer used to store values.
  • You can store different data type in variables, like integer, float, string etc...
  • Python automatically reserves the memory location for each variable. 

Identifiers

  • The name given to entities like variable, function, objects etc., is called Identifiers.
  • Variables and Identifiers are not same, but name given to a variable is called Identifier, but variables also has different properties like value, type, scope and so on.... 

Valid Identifier Name

  • Identifiers care case sensitive
  • It only contains Letter, Numbers and underscore
  • It cannot start with numbers
  • It cannot use space between two names. eg: Area of rectangle = 30
    • but use "_" : eg:  Area_of_rectangle = 30
  • Name cannot be same as Python Keywords.
Identifier in Python, How to name an identifier

Python Keywords

Keywords for Python

Some Suggestions 

  • Use descriptive identifiers to name your variable.
  • When your identifiers (variable name) has more than one word use "_" to separate them
    • eg: Rectangular_Area = Rectangle_height  * Rectangle_width.
  • Comments: Always use comments in a program so that program becomes more readable and in future you can understand meaning of each line. 
  • In Python Comments starts with use of '#' symbol.

Expression

  • Expression is any section of code that evaluate to a value
  • eg: 4   #it is an expression since it evaluate the value 4 which is an integer variable Type.
  • 3 + 4   # it is an expression since it evaluate the value 7, here 3 & 4 are also expression but                       called as sub-expression.

Statement

  • A statement is an instruction that Python can execute
  • eg: z = 2 + 8   #here 2 + 8 is an expression and whole z = 2+8 is assignment statement. 

Assignment Statement

  • An assignment is a statement that  associates names with value in your program
  • eg: variable_name = expression.

Get input from Keypad

  • To get an input from keyboard use a function input in Python.
                    input([prompt])
  • eg: Name = input ("What is your name")
variables in Python, identifiers in Python, statement in Python, Input in Python

Comments

Popular Post

Python Data Types

Python String

Python List