text: # -*- coding: utf-8 -*-
  
  
  ##############################################
  
  #
  import numpy as np
  import cv2
  
  """
  # To make an array
  tab_zeros = np.zeros(12, dtype = np.int32)
  tab_list = [1, 2, 3-4, 6, -9]
  tab_from_list = np.array(tab_list)
  
  
  # To make a function
  def myFunction(param1, param2) :
      print('Coucou')
      return param1+param2
  
  #print (myFunction(12, 9))
  
  # To make a sum function
  def mySum(param1, param2) :
      '''
      Function that sums the two input params 
      Args :
          param1: an in value
          param2: an in value
          
      Returns the Sum
      '''
      return param1+param2
  
  #print('sumTest=', mySum(1,2))
  
  # Basique algorithm without function
  for id in range(len(tab_from_list)) :
      #print('tab['+str(id)+']='+str(tab_from_list[id]))
      #print('tab[[{index}]={val}'.format(index=id,val=tab_from_list[id]))
      
      if tab_from_list[id] > 0 :
          som += tab_from_list[id]
          n += 1
          
  moy = som/n
  #print(moy)
  """
  
  tab_list = [1, 2, 3-4, 6, -9, 8, 10, 1, 5]
  tab_from_list = np.array(tab_list)
  tab_list = np.ndarray.tolist(tab_from_list)
      
  
  """    
  Question 1 : Averaging
  
      a - If Som isn't initialized, Som will take random value 
          and the result  will not be correct.
      b - Som and N will take value : 0. 0/0 will probably doing a error
      c - See below
  """
  
  def average_above_zero(table_list):
      ##
      # Function that sums from an array list
      # @table_list table_list the array list
      #
      
      if not isinstance(table_list, list) :
          raise ValueError('average_above_zero, expected a list')
      
      som = 0
      n = 0
      
      for id in range(len(table_list)) :
      
          if table_list[id] > 0 :
              som += table_list[id]
              n += 1
              
          moy = som/n
          
      if n == 0 :
          raise ValueError('Error : disivion by 0 impossible')
          
      # return 2 numbers max after coma    
      return round(moy, 2)
  
  # Display the result of the function average_above_zero with tab_from_list
  #print(average_above_zero(tab_list), " : the sum from a list of value")
  
  
  
  """
  Question 2 : Table maximum value
  """
  
  # The max value from tab_list
  #print(np.amax(tab_list))
  # Get the indices of maximum element in numpy array
  #result = np.where(tab_list == np.amax(tab_list))
  #print(result[0])
  
  
  max_val = 0
  index_max_val = 0
  
  def max_value(table_list) :
      ##
      # Function that find the max value and it's index from an array list
      # @table_list table_list the array list
      #
      if not isinstance(table_list, list) :
          raise ValueError('max_value, expected a list')
          
      #max value
      max_val = np.amax(table_list)
      
      #index max value
      index_max_val = np.where(table_list == np.amax(table_list))
      index_max_val = index_max_val[0]
  
      #return the max value and it's index
      return float(max_val), int(index_max_val[0])
  
  # Display the max value and it's of the function max_value with tab_from_list
  #print(max_value(tab_list), " : the max value with his index")
  
  
  
  """
  Question 3 : Reverse a table:
  """
  
  """
  # Algorithm
  for id in range (len(a)/2) :
      
      tmp = a[-1]
      a.pop()
      a.insert(0, temp)
      
  ### or ###
      
  for id in range (int(len(a)/2)) :
      tmp = a[id]
      a[id] = a[len(a)-id]
      a[len(a)-id] = tmp
  
  ### or ###
      
  buffer = len(a)
  turns = int(buffer/2)  
      
      
  for id in range (turns) :
      oppid = buffer-id
      tmp = a[id]
      a[id] = a[oppid]
      a[oppid] = tmp
  """
  
  
  def reversed_table(table_list):
      ##
      # Function that reverse an array list with the function reversed()
      # @table_list table_list the array list
      #
      if not isinstance(table_list, list) :
          raise ValueError('reversed_table, expected a list')
      
      return [ele for ele in reversed(table_list)] 
      
      
  #print(tab_list, " : the array")
  #print(reversed_table(tab_list), " : the array reversed with reversed()")
      
  
  #[1,5,6,2,4,9]
  def reverse_table(table_list):
  	##
      # Function that reverse an array list
      # @table_list table_list the array list
      #
      if not isinstance(table_list, list) :
          raise ValueError('reverse_table, expected a list')
          
      buffer = len(table_list)-1				#6
      turns = int(buffer/2)  					#3
          
          
      for id in range (turns) :				#first loop
          oppid = buffer-id 					#5
          tmp = table_list[id]				#1
          table_list[id] = table_list[oppid]	#[9,5,6,2,4,9]
          table_list[oppid] = tmp				#[9,5,6,2,4,1]
          
      return (table_list)
  
  #reverse_table(tab_list)
  #print(tab_list," : the array reversed with my function reverse_table")
  
  
  
  """
  Question 4 : Bounding box
  """
  
  
  #matrix = np.zeros((10,10), dtype=np.int32)
  #matrix[3:6, 4:8] = np.ones((3,4), dtype=np.int32)
  
  """
  for idrow in range(matrix.shape[0]) :
      for idcol in range(matrix.shape[1]) :
          pixVal = matrix[idrow, idcol]
  """
  
  
  
  # img = cv2.imread('image.png', 0)
  # cv2.imshow('read image', img)
  # cv2.waitKey()
  
  
  # gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  # ret, thresh = cv2.threshold(gray, 80, 255, cv2.THRESH_BINARY)
  
  # _, contours, _ = cv2.findContours(thresh,
  #                                   cv2.RETR_TREE,
  #                                   cv2.CHAIN_APPROX_NONE)
  
  # x1, y1, w, h = cv2.boundingRect(contours[0])
  # x2, y2 = x1 + w, y1 + h
  # print((x1, y1), (x2, y2)) 
  # cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
  
  # cv2.imwrite('image.jpg', img)
  
  def roi_bbox(the_image):
      ##
      # Function that display the bounding box of image
      # @the_image: the image
      #
      if not(isinstance(the_image, np.ndarray)):
          raise TypeError('roi_bbox, expected an image')
      
      image_row = the_image.shape[0]
      image_col = the_image.shape[1]
  	
      image_min_px_row = image_row
      image_max_px_row = 0
      image_min_px_col = image_col
      image_max_px_col = 0
      
      for px_row in range(image_row):
          for px_col in range(image_col):
              px_val = the_image[px_row, px_col]
              if px_val == 255:					# if px is black
                  if px_row > image_max_px_row:	# if the current px is > last max px
                      image_max_px_row = px_row	# max px row value == current px row value
                  if px_row < image_min_px_row:	# if the current px is > last min px
                      image_min_px_row = px_row	# min px row value == current px row value
                  if px_col > image_max_px_col:	# same as row for column
                      image_max_px_col = px_col
                  if px_col < image_min_px_col:
                      image_min_px_col = px_col
  		# repeat col analyse for each row 
  	# end loop row
  
      return np.array([[image_min_px_row, image_min_px_col], 
  					[image_min_px_row, image_max_px_col], 
  					[image_max_px_row, image_max_px_col], 
  					[image_max_px_row, image_min_px_col]])
  
  
  
  """
  Question 6 : Remove whitespace characters in a string
  """
  
  string = "This is a test"
  #print(string, " : The string with his space chars")
  """
  # Algorithm
  for char in string:
      if (char == ' ') :
          remove char
  """
  def remove_whitespace(string) : 
      ##
      # Function that remove white space in a string
      # @string string is a string
      #
      if not isinstance(string, str) :
          raise ValueError('remove_whitespace, expected a string')
          
      newString = string.replace(' ', '')
      
      return newString
  
  #print (remove_whitespace(string), " : The string without his space chars")
  
  
  
  
      