Page 102 - Computer_Genius_v2.1_C7_flipbook
P. 102

2. Subtraction

                  Subtraction operation is used to perform mathematical subtraction of two variables. In programming,
                  we refer to “-” as a symbol of subtraction. Please note that subtraction can only be carried out on
                  Integer, Float, Double data types.

                  Example:                    print (10–5)           5


                  3. Multiplication

                  Multiplication operator  is used to find the mathematical product of two variables. In programming,
                  we refer to ‘*’ as a symbol of multiplication. Please note that multiplication can only be carried out
                  on Integer, Float and Double data types.

                  Example:                    print (10*5)           50


                  4. Division
                  Division operator  is used to perform the mathematical division of two variables. In programming,
                  we refer to ‘/’ as a symbol of division. Please note that Division can only be carried out on Integer,
                  Float and Double data types.

                  Example:                    print (10/5)           2


                  5. Modulus
                  Modulus operator  is used to perform the mathematical remainder of two variables. In programming,
                  we refer to ‘%’ as a symbol of modulus. The operator divides the variable on the left to the variable
                  on right and returns the remainder. Please note that modulus can only be carried out on integer and
                  float data types in Python.

                  Example:                    print (10%5)           0
                  Total Distance Covered by a Vehicle

                  To create an AI Connect program to find the total distance, create a project. In this project create
                  a Basic Coding activity. Then follow the given steps:

                  (Here, the speed of the vehicle is 40 Km/hrs and time taken to cover journey is 120 minutes to find
                  the total distance covered in Km. We can change the values in this program).
                  (Hint: Convert minutes into hours).
                   Step 1   Print the information for the readers and define a variable “speed”, and set its value to 40.


                              Block Code












                      100    Computer Genius (V2.1)-VII
   97   98   99   100   101   102   103   104   105   106   107