input: Write a function to calculate the maximum possible revenue from the items with given weights and values using a knapsack approach. Given the weights and values of items, the function should return the maximum revenue that can be obtained with a knapsack of capacity 5.
  
  def knapsack(weights, values, n):
      W = 5
      K = [[0 for x in range(W+1)] for x in range(n+1)]
      
      for i in range(n+1):
          for w in range(W+1):
              if i==0 or w==0:
                  K[i][w] = 0
              elif weights[i-1] <= w:
                  K[i][w] = max(values[i-1] + K[i-1][w-weights[i-1]],  K[i-1][w])
              else:
                  K[i][w] = K[i-1][w]
                  
      return K[n][W]
  
  weights = [2, 1, 3]
  values = [4, 2, 3]
  n = len(weights)
  assert knapsack(weights, values, n)==7
  
  weights = [1, 3, 4]
  values = [1, 4, 5]
  n = len(weights)
  assert knapsack(weights, values, n)==9
  
  weights = [2, 2, 3]
  values = [3, 2, 4]
  n = len(weights)
  assert knapsack(weights, values, n)==7
  
  weights = []
  values = []
  n = len(weights)
  assert knapsack(weights, values, n)==0
  
  weights = [1, 1, 1, 1]
  values = [1, 2, 3, 4]
  n = len(weights)
  assert knapsack(weights, values, n)==5
output: def knapsack(weights, values, n):
      W = 5
      K = [[0 for x in range(W+1)] for x in range(n+1)]
      
      for i in range(n+1):
          for w in range(W+1):
              if i==0 or w==0:
                  K[i][w] = 0
              elif weights[i-1] <= w:
                  K[i][w] = max(values[i-1] + K[i-1][w-weights[i-1]],  K[i-1][w])
              else:
                  K[i][w] = K[i-1][w]
                  
      return K[n][W]