<jupyter_start><jupyter_text>Basic Programming 8  1. Write a Python Program to Add Two Matrices?<jupyter_code>import numpy as np

mat1=np.arange(8).reshape(2,4)
mat2=np.random.randint(1,17,8).reshape(2,4)
print(mat1)
print()
print(mat2)
print()

print(np.add(mat1,mat2))<jupyter_output>[[0 1 2 3]
 [4 5 6 7]]

[[14 13 15  7]
 [ 2 15 13  5]]

[[14 14 17 10]
 [ 6 20 19 12]]<jupyter_text>2. Write a Python Program to Multiply Two Matrices?<jupyter_code>import numpy as np

mat1 = np.array([[1,2,4],
        [4,5,6],
        [7,8,9]])
mat2 = np.array([[2,3,4],
        [5,6,7],
        [8,9,1]])

sumMat = np.dot(mat1,mat2)
print("The product of two matrix \n\n{}  and \n\n{}  is \n\n{} ".format(mat1,mat2,sumMat))<jupyter_output>The product of two matrix 

[[1 2 4]
 [4 5 6]
 [7 8 9]]  and 

[[2 3 4]
 [5 6 7]
 [8 9 1]]  is 

[[ 44  51  22]
 [ 81  96  57]
 [126 150  93]]<jupyter_text>3. Write a Python Program to Transpose a Matrix?<jupyter_code>mat1 = np.array([[1,2,4],
        [4,5,6],
        [7,8,9]])
print(mat1.T)
M = [[2,3,4],
     [4,3,5]]

R= [[0,0],
     [0,0],
     [0,0]]

for i in range(len(M)):
    for j in range(len(M[0])):
        R[j][i] = M[i][j]
for i in R:
    print(i)<jupyter_output>[2, 4]
[3, 3]
[4, 5]<jupyter_text>4. Write a Python Program to Sort Words in Alphabetic Order?<jupyter_code>input_str = 'my name is chitti the robot'

# breakdown the string into a list of words
words = input_str.split()

# sort the list
words.sort()

print("The sorted words are:")
for word in words:
    print(word)<jupyter_output>The sorted words are:
chitti
is
my
name
robot
the<jupyter_text>5. Write a Python Program to Remove Punctuation From a String?<jupyter_code>punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''

str = input("Enter some string with panctuations")

# remove punctuation from the string
no_punct = ""
for char in str:
    if char not in punctuations:
        no_punct = no_punct + char

# display the unpunctuated string
print(no_punct)<jupyter_output>Enter some string with panctuationssurprised!,may be we can #sleep & Start *early @tomorrow
surprisedmay be we can sleep  Start early tomorrow
{'fraction_non_alphanumeric': 0.16094117647058823, 'fraction_numerical': 0.07011764705882353, 'mean_word_length': 3.7775280898876407, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '265393', 'license': 'CNRI-Python', 'n_tokens_mistral': 965, 'n_tokens_neox': 889, 'n_words': 255, 'path': 'Python Programming basics 8.ipynb', 'repo_name': 'RitheshMacom/Python-basic-programming', 'size': '2125'}