Page 246 - AI Computer 10
P. 246

u A meaningful name should be used for a variable.

             u The first character must be a letter or an underscore.
             u Variable name is made up of the following characters a-z, A-Z, 0-9 and underscore(_).
             u Upper and lower case letters are different.
             u A variable name must not be a keyword of Python such as else, print, if, etc.

             u A variable name must not contain any special characters except underscore.
            Some examples of valid and invalid variable name are given below:

                                                      Valid                 Invalid

                                                    student_1              1 student

                                                     Myfile                 My.file

                                                   _Program1               .Program1

            You  should  remember  that Python  is  a case-sensitive language as it  considers upper-case and  lower-case
            differently.
            Assigning Values to Variables

            Values are assigned to a variable using the equal to (=) sign. For example, a = 10.
            Here, 10 is assigned as a value to the variable we used 'a'.




              Python will let you assign the same value to multiple variables in one statement.

            The syntax for assigning a value to the variable is:

                      Variable_name= variable_value
            Example:









            Text value can also be assigned to a variable name.









            Data Types

            A data type is an attribute that tells the computer what kind of data a variable can have. The concept of data type
            is mostly used in those programming languages where the type of variable is known at compile time. Each data
            type requires different amounts of memory and has some specific operations which can be performed over it.
            Some of the commonly used data types in Python programming language are as follows:




                112
                112
   241   242   243   244   245   246   247   248   249   250   251