πŸ“’ Too many exams? Don’t know which one suits you best? Book Your Free Expert πŸ‘‰ call Now!

  • google app store apple app store
  • βœ–

      Question

      Complete the Python code to print the elements of the

      main diagonal of a square matrix matrix of size N x N. def print_main_diagonal(matrix, N): Β  Β  for i in range(N): Β  Β  Β  Β  _________ # Line to complete
      A print(matrix[i][N - 1 - i]) Correct Answer Incorrect Answer
      B print(matrix[i][0]) Correct Answer Incorrect Answer
      C print(matrix[0][i]) Correct Answer Incorrect Answer
      D print(matrix[i][i]) Correct Answer Incorrect Answer
      E print(matrix[N - 1 - i][i]) Correct Answer Incorrect Answer

      Solution

      The correct answer is D

      Practice Next
      ask-question