Page 132 - Computer Genius Class 07
P. 132

Variable
                  Variables are containers for storing data values.

                  A variable is a name which refers to a value. A variable is created when a value is assigned with the
                  help  of an assignment operator (=). print() statement is used to display the values of variables.

                              Block Code
















                             Textual code


















                  The rules for naming a variable in Python are as follows:
                  l   The name should begin with an uppercase or a lowercase alphabet or an underscore sign (_). This
                     may be followed by any combination of characters a-z, A-Z, 0-9 or underscore (_). A variable
                     cannot start with a digit.

                  l   It can be of any length. It is preferred to keep it short and meaningful.

                  l   It should not be a keyword or reserved word.
                  l   Special symbols like !, @, #, $, %, and so on cannot be used in variables.


                  Input Command
                  The input() function allows user input. There are two types of input commands:

                  (a) Asking the user to provide the input.

                  Example: Asking for name.

                              Block Code







                      130    Computer Genius-VII
   127   128   129   130   131   132   133   134   135   136   137