<jupyter_start><jupyter_text>Write a Python Program to Add Two Matrices?Matrices of same order can be added<jupyter_code>m1=[[1,2,5],[3,9,8],[5,7,3]]
m2=[[-7,4,8],[1,8,3],[4,6,-5]]
result=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(len(m1)):
    for j in range(len(m1[i])):
        result[i][j]=m1[i][j]+m2[i][j]
print("The sum of \n {} \n and \n{}\n is: \n {}".format(m1,m2,result))
import numpy as np
m1=np.array([[1,2,5],[3,9,8],[5,7,3]])
m2=np.array([[-7,4,8],[1,8,3],[4,6,-5]])
result=np.add(m1,m2)
print(result)<jupyter_output>[[-6  6 13]
 [ 4 17 11]
 [ 9 13 -2]]<jupyter_text>Write a Python Program to Multiply Two Matrices?Two matrices of the type m x n and n x p can be multiplied i.e. no. of rows of one matrix is equal to no. of rows of another<jupyter_code>m1=[[1,2,5,4],[3,9,8,-4],[5,7,3,2]] #3x4
m2=[[-7,4,8],[1,8,3],[4,6,-5],[5,2,-2]]  #4x3
result=[[0,0,0],[0,0,0],[0,0,0]] #result is 3x3
for i in range(len(m1)):
    for j in range(len(m2[i])):
        for k in range(len(m2)):
            result[i][j]+=m1[i][k]*m2[k][j]
print(result)

m1=np.array([[1,2,5,4],[3,9,8,-4],[5,7,3,2]]) #3x4
m2=np.array([[-7,4,8],[1,8,3],[4,6,-5],[5,2,-2]])  #4x3
result=np.dot(m1,m2)
print(result)<jupyter_output>[[ 35  58 -19]
 [  0 124  19]
 [ -6  98  42]]<jupyter_text>Write a Python Program to Transpose a Matrix?<jupyter_code>m1=[[1,2,5,4],
    [3,9,8,-4],
    [5,7,3,2]]
result=[[0,0,0],
        [0,0,0],
        [0,0,0],
        [0,0,0]]
for i in range(len(m1)):
    for j in range(len(m1[i])):
        result[j][i]=m1[i][j]
print(result)
m1=np.array([[1,2,5,4],
    [3,9,8,-4],
    [5,7,3,2]])
print(m1.transpose())<jupyter_output>[[ 1  3  5]
 [ 2  9  7]
 [ 5  8  3]
 [ 4 -4  2]]<jupyter_text>Write a Python Program to Sort Words in Alphabetic Order?<jupyter_code>str = input("Enter some string: ")
str=str.lower()
words = str.split()
words.sort()
for word in words:
    print(word)<jupyter_output>Enter some string: This is full stack data science assignment
assignment
data
full
is
science
stack
this<jupyter_text>Write a Python Program to Remove Punctuation From a String?<jupyter_code>punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''
str=input("Enter text to remove punctuations: ")
str1=""
for i in str:
    if i not in punctuations:
        str1=str1+i
print("String after punctuations are removed is: ",str1)<jupyter_output>Enter text to remove punctuations: Punctuations to remove !a()b-cf[]g{}g;:'gh"\j,<>./?@#$%^&*_~
String after punctuations are removed is:  Punctuations to remove abcfggghj
{'fraction_non_alphanumeric': 0.2315369261477046, 'fraction_numerical': 0.08902195608782436, 'mean_word_length': 4.708428246013668, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, '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': '347955', 'license': 'CNRI-Python', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1155, 'n_words': 249, 'path': 'Python Basic Programming_8.ipynb', 'repo_name': 'kartik-mittal/Python-Programming-Basic', 'size': '2505'}