Page 85 - Digicode_AI_class_7
P. 85

In the  previous  chapter,  you  have  learned  what  is Python,  its features,  how  to  install  Python,
            programming in Python and variable.
            In this chapter, you will learn about data types, comments, operators and its precedence.


            Data Types
            Data types are used to define the type of value a data can contain. Each variable in Python is associated
            with some data type. Each data type requires a different amount of memory and has some specific
            operations performed on it.  Data types are divided into four categories as shown below:



                                                               Data Types




                               Numbers                   Sets              Sequence              Boolean




                 Integer/long               Float               String                   Lists





                               Complex                                       Tuple
            Number

            Integer numbers, floating-point numbers, and complex numbers are the built-in numeric data types
            of Python.

            Integer/Long

            Integers are whole numbers consisting of + or – signs. They do not have decimal places between
            them.
            The range of an integer can be from -2147483648 to 2147483647.

            Float

            Float data types represent numbers that contain a decimal point. For example, 0.6, -3.257 are called
            floating-point numbers. These numbers can also be written using ‘e’ or ‘E’ to represent the power 10.

            Complex
            A complex is a number that is written in the form a+ bj or a+bJ. It is represented as (real part) +
            (imaginary part) j.

            Sets

            Set is a mutable, unordered collection of values, of any type, with no duplicate element.

            Sequence

            A sequence is an ordered collection of items of similar or different data types. The three types of
            sequence data types are Strings, Lists and Tuples.

                                                                                       More on Python     83
   80   81   82   83   84   85   86   87   88   89   90