Edit Template
Edit Template
Edit Template

NumPy Exercise

Create a NumPy array with the elements [1, 2, 3, 4, 5].
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(arr)
[[1, 2, 3],
 [4, 5, 6]]
 
 
 import numpy as np
arr = np.array([[1, 2, 3], [4, 5, 6]])
print(arr)
import numpy as np
arr = np.zeros((3, 3))
print(arr)
import numpy as np
arr = np.random.rand(2, 4)
print(arr)
#array

arr = [1, 2, 3, 4, 5]

#solution

import numpy as np
arr = np.array([1, 2, 3, 4, 5])
mean_value = np.mean(arr)
print(mean_value)
#array

arr = [10, 20, 5, 30, 15]

#solution

import numpy as np
arr = np.array([10, 20, 5, 30, 15])
max_value = np.max(arr)
print(max_value)
#array

arr1 = [1, 2, 3]
arr2 = [4, 5, 6]

#solution

import numpy as np
arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])
dot_product = np.dot(arr1, arr2)
print(dot_product)
#array

arr1 = [1, 2, 3]
arr2 = [4, 5, 6]

#solution

import numpy as np
arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])
result = arr1 + arr2
print(result)
import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6])
reshaped_arr = arr.reshape(2, 3)
print(reshaped_arr)
#given 2d array

[[1, 2, 3],
 [4, 5, 6],
 [7, 8, 9]]
 
 #extract the subarry
 
 [[2, 3],
 [5, 6]]
 
 #solution
 
 import numpy as np
arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
subarray = arr[0:2, 1:3]
print(subarray)
  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
Python List

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python String

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Loops

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Conditional Statements

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Operators

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Data Type

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Scikit-learn

Scikit-learn Tutorial Scikit-learn Hamburger Toggle Menu Edit Template Scikit learn in Hindi What is Scikit-learn in Hindi Scikit learn एक...

Pandas

Pandas Tutorial Pandas Hamburger Toggle Menu Edit Template Pandas in Hindi What is Pandas in Hindi pandas  एक python library...

NumPy

NumPy Tutorial NumPy Hamburger Toggle Menu Edit Template NumPy in Hindi What is NumPy in Hindi matplotlib का use हम...

Edit Template
Scroll to Top