Page 291 - Data Science class 11
P. 291

12.  Modulo Operator

                  a. What is the remainder when 15 is divided by 4 using the modulo operator (%%)?
              Ans.  15%%4
                  Output
                  [1] 3

                  b. Calculate the remainder when 27 is divided by 5 using the modulo operator.
              Ans.  27%%5
                  Output

                  [1] 2
              13.  Exponentiation:

                  a. Raise 3 to the power of 4 using the ^ operator.
              Ans.  3 ^ 4
                  Output

                  [1] 81
                  b. Compute the square root of 64 using the sqrt() function.

              Ans.  sqrt(64)
                  Output
                  [1] 8
              14.  Combining Operators

                  a. Given the variables a = 10 and b = 3, find the result of a + b * 2.
              Ans.  10+3*2

                  Output
                  16
                  b. Evaluate the expression (8 + 2) / 2 and explain the order of operations.
              Ans.  (8+2)/2
                  Output

                  5
                  Order of operations: first operation addition inside the parenthesis, then addition with 2.
              15.  Mixed Operations:

                  a. Create an expression that involves addition, subtraction, multiplication, and division.
              Ans.  9+2-1*2/10
                  (can find the result of this expression as follows
                  9+2-2/10
                  9+2-0.2
                  11-0.2

                  10.8
                  Output
                  [1]  10.8



                                                                                          Practical Questions  289
   286   287   288   289   290   291   292   293   294   295   296