Saturday, 3 November 2012

How to Declare Variables in Python?

Variables:

A symbolic name which can associated with a value and whose associated value may be changed. But some Rules are also applied on the declaration of a variable in programming languages.

Some Rules for Declaration of Variable:

1)   Variable name must be descriptive.
Example: Such as  if u want to take a value of number then the variable name should be "number"

2)   Variable name must be start from underscore sign ( _ ) or any alphabet letter.
Example: abc or _abc both are valid Variables.

3)   Variable can't be declared with any number.
Example : 12num: this is wrong way to declare variable. Interpreter will generate syntax error.

4)   No white Spaces between lengthy variable at that place use underscore
Example:  no of things this is a wrong variable use no_of_things.

No comments:

Post a Comment