Page 116 - Computer Genius Class 08
P. 116

Data Types

                   ata types are the classification or categorisation of data items. It represents the kind of value that
                  tells what operations can be performed on a particular data.

                                                           Python Data Types



                                      Numeric     Dictionary    Boolean       Set       Sequence Type



                         Integer       Float     Complex No.                   Strings       List        Tuple


                        Name          Type                                  Description

                    Integers        int        Whole numbers, such as: –2 3 300 200

                    Floating point float       Numbers with a decimal point: 2.3 4.6 100.0
                    Strings         str        Ordered sequence of characters: "hello" 'Sammy' "2000"

                    Lists           list       Ordered sequence of objects: [10, "hello", 200.3]

                    Dictionaries    dict       Unordered Key: value pairs: ("mykey" : "value", "name" : "Frankie")

                    Tuples          tup        Ordered immutable sequence of objects: (10, "hello", 200.3)
                    Sets            set        Unordered collection of unique objects: ("a","b")

                    Booleans        bool       Logical value indicating True or False

                  Variables

                  A variable is a named location which is used to store data in the memory. It is helpful to think of
                  variables as a container that holds data which can be changed later through programming.

                  Python is called dynamic typing language, as variables can be defined at the runtime also.  ariables
                  can be declared at the time of assignment.
                  Example:
                  a= 10

                  b= 2.1
                  c= 'N'
                  d= "Hello World"
                  Here, we have created four variables named  a, b, c and d assigned
                  with the values 10, 2.1, 'N', "HelloWorld" respectively. You can

                  think variable as a container to store things and those things can
                  be replaced at any time.
                  Example:

                  a=10
                  a=20                                                                      Rules for naming variables


                       114   Computer Genius-VIII
   111   112   113   114   115   116   117   118   119   120   121