Grade An Exam (program that grades multiple-choice tests)

def main(): # Students’ answer to the questions answers = [ [‘A’, ‘B’, ‘A’, ‘C’, ‘C’, ‘D’, ‘E’, ‘E’, ‘A’, ‘D’], [‘D’, ‘B’, ‘A’, ‘B’, ‘C’, ‘A’, ‘E’, ‘E’, ‘A’, ‘D’], [‘E’, ‘D’, ‘D’, ‘A’, ‘C’, ‘B’, ‘E’, ‘E’, ‘A’, ‘D’], [‘C’, ‘B’, ‘A’, ‘E’, ‘D’, ‘C’, ‘E’, ‘E’, ‘A’, ‘D’], [‘A’, ‘B’, ‘D’, ‘C’, … Read moreGrade An Exam (program that grades multiple-choice tests)

Random Shuffling A matrix

import random matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # Assume a list is given for row in range(len(matrix)): for column in range(len(matrix[row])): i = random.randint(0, len(matrix) – 1) j = random.randint(0, len(matrix[row]) – 1) # Swap matrix[row][column] with matrix [i][j] matrix[row][column], matrix[i][j] = matrix[i][j], matrix[row][column] for row in range(len(matrix)): for … Read moreRandom Shuffling A matrix

Initialize Matrix with random values

import random matrix = [] # Create an empty list numberOfRows = eval(input(“Enter the number of rows: “)) numberOfColumns = eval(input(“Enter the number of columns: “)) for row in range(numberOfRows): matrix.append([]) #add an empty new row for column in range(numberOfColumns): matrix[row].append(random.randint(0, 99)) for row in matrix: for value in row: print(value, end=” “) print() # … Read moreInitialize Matrix with random values

Initialize a Matrix and enter elements

matrix = [] # Create an empty list numberOfRows = eval(input(“Enter the number of rows: “)) numberOfColumns = eval(input(“Enter the number of columns: “)) for row in range(numberOfRows): matrix.append([]) #add an empty new row for column in range(numberOfColumns): value = eval(input(“Enter an element and press Enter: “)) matrix[row].append(value) print(matrix)