Page 199 - Ai Book - 10
P. 199

Here, ‘=’ operator assigns the value written on the right hand side to the left side of the variable. Python also
        offers augmented assignment operators in  which  an  arithmetic  operator is  combined  with  the assignment
        operator. For example, if a=10, then a+=10 is equal as a=a+10.
        Example:







               Pop Quiz
               Pop Quiz
          Arrange the following operators as per the Precedence rule.
          (),   >,   %,   /,   >=,   <=,   *,   **,   +,   ==,   !=


        Type Conversion

        Type conversion refers to the process of converting the value of one datatype to another datatype. The two
        types of data type conversion supported by Python are as follows:

         u   Implicit  Type  Conversion: In Implicit  type  conversion, Python  automatically converts  one data type  to
             another data type. This process doesn’t need any user involvement.

             Example:












         u   Explicit Type Conversion: In Explicit Type Conversion, users convert the data type of an object to required
             data type. You can use the predefined functions like int(), float(), str(), bool (), complex(), tuple(), etc. to
             perform explicit type conversion. This type of conversion is also called typecasting because the user casts
             (changes) the data type of the objects.

             Example:

















        The input() function

        The input() function is used to accept input value from the user. When this statement executes, the flow of the
        program stops until user enters the value at blinking cursor position. Note that the input given by the user is


                                                                                                              73
                                                                                                              73
   194   195   196   197   198   199   200   201   202   203   204