<jupyter_start><jupyter_text><NAME>  Reg No : 180905048 Roll No 11 C Lab3  Q1 Write a program to find the factors of a given number (get input from user) using for loop.<jupyter_code>def print_factors(x):
   print("The factors of",x,"are:")
   for i in range(1, x + 1):
       if x % i == 0:
           print(i)
            
num=int(input("Enter Number:"))
print_factors(num)<jupyter_output>Enter Number:30
The factors of 30 are:
1
2
3
5
6
10
15
30<jupyter_text>Q2 Find the sum of columns and rows using axis<jupyter_code>import numpy as np
a=np.arange(20).reshape(4,5)
print(a.sum(axis=1))
print(a.sum(axis=0))<jupyter_output>[10 35 60 85]
[30 34 38 42 46]<jupyter_text>Q3     3. Operations on Arrays (use numpy wherever required):    a) Create array from list with type float    b) Create array from tuple    c) Creating a 3X4 array with all zeros    d) Create a sequence of integers  from 0 to 20 with steps of 5    e)  Reshape 3X4 array to 2X2X3 array    f) Find maximum and minimum element of array, Row wise max and min, column wise max and min and sum of elements. (Use functions max(), min(), sum())<jupyter_code># a
a=np.array([1,2,3,4.0])
a.dtype
# b
a=np.array((1,2,3,4.0))
a.dtype
# c
np.zeros(12).reshape(3,4)
# d
a=np.arange(0,20,5)
a
# e
a=np.arange(12).reshape(3,4).reshape(2,2,3)
a
# f
a=np.arange(12).reshape(3,4)
a.sum(axis=0)
a.sum(axis=1)
a.max(axis=0)
a.max(axis=1)
a.min(axis=0)
a.min(axis=1)<jupyter_output><empty_output><jupyter_text>Q4 Write a program to transpose a given matrix.<jupyter_code>a=np.arange(25).reshape(5,5)
a
s1=0
for i in range(0,len(a)):
    for j in range(0,len(a[0])):
        if(i>j):
            temp=a[i][j]
            a[i][j]=a[j][i]
            a[j][i]=temp
a
#OR
a
a.T<jupyter_output><empty_output><jupyter_text>Q5 Write a program to add two matrices.<jupyter_code>a=np.arange(25).reshape(5,5)
b=np.arange(25).reshape(5,5)
res=np.zeros(25).reshape(5,5)

for i in range(0,len(a)):
    for j in range(0,len(a[0])):
        res[i][j]=a[i][j]+b[i][j]
res
res=a+b
res<jupyter_output><empty_output><jupyter_text>Q6 Write a program to find element wise product between two matrices.<jupyter_code>a=np.arange(25).reshape(5,5)
b=np.arange(25).reshape(5,5)
res=np.zeros(25).reshape(5,5)

for i in range(0,len(a)):
    for j in range(0,len(a[0])):
        res[i][j]=a[i][j]*b[i][j]
res
# OR

res=a*b
res<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16, 'fraction_numerical': 0.06147368421052631, 'mean_word_length': 4.303571428571429, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 25, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '546855', 'license': 'MIT', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1025, 'n_words': 255, 'path': 'Distributed Systems/lab3/Untitled1.ipynb', 'repo_name': 'Sahil1515/Sem6-Labs', 'size': '2388'}