Page 72 - ModularV1.1 _c8_flipbook
P. 72

Rules for Naming Variables

                  The rules for naming a variable are:
                  (i)  A variable name must start with a letter (a–z, A–Z) or an underscore (_).
                  (ii)  A variable name cannot start with a digit.
                  (iii) Keywords cannot be used as variable names.

                  (iv)  A variable can only contain alpha-numeric characters and underscore (A–Z both capital as
                      well as small) and (0–9) numbers.
                  (v)  No special symbols like ! , @ , #, $, %, etc. can be used in variable name.
                  (vi) Variable names are case-sensitive.
                  Examples of some valid variable names:
                  Gaurav123,  mygood_book,  _usha93,  MiraYadav,  age,  etc.
                  Examples of some invalid variables:
                  1_Name, @Address, 1234, –Age
                  Multiple Variable Assignment

                  Python allows us to assign a single value to several variables simultaneously.
                  For example,
                         a = b = c = 32
                  In the above example, all the variables a, b and c will be assigned the value 32. We can also assign
                  multiple values to multiple variables simultaneously.
                  For example,
                         a, b, c = 32,  96.4 , “Aryan”
                  In the above example, variable a will be assigned value 32, variable b will be assigned value 96.4
                  and variable c will be assigned value “Aryan”.
                      CHARACTER SET

                  Character set means characters such as alphabet, digits or special symbols that can be used to
                  write programs in Python language.
                  Alphabet          A–Z  or  a–z
                  Digits            0–9
                  Special symbols  ~ ‘ ‘ ! @ # $ % ^ &  ( ) * - _ + = : \ ] {  } ; “ < > , ? | `

                      KEYWORDS
                  These are the reserved words that cannot be used as variable names as they carry a special
                  meaning for the interpreter. In Python, keywords are case sensitive.

                  Examples of some keywords in Python are:
                  True, elif, del, if, None, False, import, else, etc.
                      DATA TYPES

                  The types of data or value that can be stored in variables are called Data Types.
                  Python has six standard data types that are as follows:

                      Number: This data type stores the numerical values including integer values, long values,
                     floating point numbers.
                     For example: a = 3 or marks = 99.5

                  70      Modular (Ver. 1.1)-VIII
   67   68   69   70   71   72   73   74   75   76   77