Exercise 64 

Write a Python function  quotient() which takes two numbers a and b as parameters and which returns the quotient and the remainder of the Euclidean division of a by b without using the operators '//' , '%'

      Solution 

      1 - Creating the function quotient():

      # Creating the function quotient():
      def quotient(a,b):
      q = 1
      if a < b :
      return 0
      else:
      while ( b*q < a):
      q = q + 1
      return (q-1 , a - b*(q-1))

      # Testing the function
      print("The quotient and remainder of the Euclidean division of 17 by 3 is (q , r) = ", quotient(17,3))

      2 - Creating the function remainder():


      Younes Derfoufi
      my-courses.net

      Leave a Reply