0% found this document useful (0 votes)
5 views2 pages

Python Exp11

The document provides examples of using Numpy to create and manipulate array objects in Python. It demonstrates creating arrays of zeros and ones, generating ranges and linspace, performing arithmetic operations, reshaping arrays, and conducting matrix multiplication. Additionally, it calculates statistical measures such as mean, median, and standard deviation of an array.

Uploaded by

vraveena10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Python Exp11

The document provides examples of using Numpy to create and manipulate array objects in Python. It demonstrates creating arrays of zeros and ones, generating ranges and linspace, performing arithmetic operations, reshaping arrays, and conducting matrix multiplication. Additionally, it calculates statistical measures such as mean, median, and standard deviation of an array.

Uploaded by

vraveena10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Numpy: Array objects :-


import numpy as np

arr = np.array([1,2,3,4,5])
print("Array: ", arr)

zeros_arr = np.zeros((3,4))
print("\nZeros Array:\n", zeros_arr)

ones_arr = np.ones((2,3))
print("\nOnes Array:\n", ones_arr)

range_arr = np.arange(0, 10, 2)


print("\nRange Array: ", range_arr)

linspace_arr = np.linspace(0, 1, 5)
print("\nLinspace Array:", linspace_arr)

sum_arr = arr + 10
print("\nArray after adding 10:", sum_arr)

mul_arr = arr * 2
print("\nArray after multiplying by 2:", mul_arr)

reshaped_arr = arr.reshape((1, 5))


print("\nReshaped Array:\n", reshaped_arr)

matrix1 = np.array([[1, 2], [3, 4]])


matrix2 = np.array([[5, 6], [7, 8]])
product = np.dot(matrix1, matrix2)
print("\nMatrix multiplication result:\n", product)

mean_val = np.mean(arr)
median_val = np.median(arr)
std_val = np.std(arr)
print(f"\nMean: {mean_val}, Median: {median_val}, Std Dev: {std_val}")
Output :

You might also like