Page 148 - Computer Science Class 11 With Functions
P. 148

7                                                    DATA TYPES AND

                                                                                     OPERATORS











          Chapter Outline


          7.1 Data Types                                     7.2 Mutable and Immutable Data Types
          7.3 Visualizing Execution of Python Code           7.4 Usage of Python Data Types
          7.5 Operators                                      7.6 Expressions
          7.7 Precedence of Operators in Python              7.8 Type conversion
          7.9 Types of Errors




        Introduction

        In the last chapter, we talked about Python's character set, tokens, variables, and input-output statements. A program
        usually takes some data, does processing on it, and gives the user the results in the form they want. Depending on the

        data type and the problem's nature, the input data must go through a number of operations before the user can get
        useful results. In this chapter, we will discuss various types of data and the associated operations.

        7.1 Data Types

        A data type refers to a type of data and the operations that can be performed on the objects of that type. For instance,
        the types int, float, and str correspond to integer, floating point, and string data. For example, 23, 12.75, and

        'Hello World' are values of types int, float, and str, respectively. A data type in Python is also called a class.
        Thus, instead of saying types int, float, and str, we can also say classes int, float, and str, respectively.
        Thus, we would say that 23, 12.75, and 'Hello  World' are objects of (or instances of) the classes int,
        float, and str, respectively. Python allows different operations to be performed on different data types. We have
        already seen examples of operations associated with the abovementioned data types. Fig 7.1 shows some important
        data types available in Python.














         146   Touchpad Computer Science-XI
   143   144   145   146   147   148   149   150   151   152   153