<jupyter_start><jupyter_text>Prelim Exam  Question 1 : 4 x 4 matrix whose diagonal elements are all one (1's).<jupyter_code>import numpy as np
# Create 4 x 4 matrix whose diagonal elements are all one (1's).

# 1st solution
C = np.diagonal([[1,2,3,4],[2,1,3,4],[3,2,1,4],[4,3,2,1]])
print(C) # this will only print all the diagonal elements which has a value of 1

# 2nd solution
C = np.zeros((4,4))
np.fill_diagonal(C,1)
print(c) # this will print the entire 4x4 matrix<jupyter_output>[1 1 1 1]
[[1. 0. 0. 0.]
 [0. 1. 0. 0.]
 [0. 0. 1. 0.]
 [0. 0. 0. 1.]]<jupyter_text>Question 2 :  show a solution that doubles all the values of each element<jupyter_code># Double all the values of the elements in Question 1

print(C * 2)<jupyter_output>[[2. 0. 0. 0.]
 [0. 2. 0. 0.]
 [0. 0. 2. 0.]
 [0. 0. 0. 2.]]<jupyter_text>Question 3 : cross-product of matrices, A = [2,7,4] and B = [3,9,8]<jupyter_code>A = [2,7,4]
B = [3,9,8]

# cross product
answer = np.cross(A,B)
print(answer)<jupyter_output>[20 -4 -3]
{'fraction_non_alphanumeric': 0.17234468937875752, 'fraction_numerical': 0.0871743486973948, 'mean_word_length': 3.7799043062200957, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '540298', 'license': 'Apache-2.0', 'n_tokens_mistral': 477, 'n_tokens_neox': 424, 'n_words': 139, 'path': 'Prelim_Exam.ipynb', 'repo_name': 'Ranniellsaur/Linear-algebra-58020', 'size': '998'}