Page 83 - Information_Practice_Fliipbook_Class11
P. 83

Python also allows scientific notation to express floating point numbers. In scientific notation, the symbol E denotes
                   base 10 for the exponent, for example,

                   >>> 1.5E2
                       150.0
                   In the above example, 15.E2 denotes the number 1.5*102. Next, let us see some more examples,
                   >>> 1E2
                       100.0
                   >>> -2.2E2
                       -220.0
                   >>> -2.2E-2
                       -0.022

            ●  Complex: A complex number is of the form x+yj and comprises a pair of floating point numbers. The first one (x)
              is called the real part, and the second one (y) is called the imaginary part. Some examples of complex numbers
              are 5+6j, 3-2j, 2+j, and so on. The real and imaginary parts of a complex number can be retrieved as shown
              below:
             >>> a = 5+6j
             >>> a
                 (5+6j)
             >>> a.real
                 5.0
             >>> a.imag
                 6.0
            Let us now examine the type of a complex object and its parts,

             >>> type(a)
                 <class 'complex'>
             >>> type(a.imag)
                 <class 'float'>
             >>> type(a.real)
                 <class 'float'>
            Note that when we write a = 5+6j, Python interprets 5 and 6 as floating point numbers.



                   In a complex number of the form x+yj, j denotes  –1.


            4.1.2 bool (Boolean)

            In Python, the  Boolean  data type  is called  bool  and  includes  two  values:  True  and  False.  An  expression
            constructed  using  Boolean  values  is  called  a  Boolean  expression.  Interestingly,  in  a  Boolean  expression,  Python
            considers the numeric value 0 as False and a numeric value other than 0 as True. Now, let us examine the following
            examples,
             >>> condition = True
             >>> type(condition)
            Output:

            <class 'bool'>
            So far, we have dealt with individual data elements. But, at times, one must deal with several data values, say, names
            of cities, marks of five subjects, details of items in a store, and so on. Sequence types available in Python are often used
            to deal with aggregates of objects.







                                                                                        Data Types and Operators  69
   78   79   80   81   82   83   84   85   86   87   88