This document describes a Python program that uses the NumPy library to create various arrays. It creates:
(a) An array of numbers from 1 to 20 in reverse order.
(b) A 2D array of size 3x4 with all elements equal to 8.
(c) An array of 10 evenly spaced values between 1 and 5.
(d) An array of 10 evenly spaced values between 1 and 10 on a log scale.
(e) An array of 10 random numbers between 1 and 100. The arrays are printed to display the results.
This document describes a Python program that uses the NumPy library to create various arrays. It creates:
(a) An array of numbers from 1 to 20 in reverse order.
(b) A 2D array of size 3x4 with all elements equal to 8.
(c) An array of 10 evenly spaced values between 1 and 5.
(d) An array of 10 evenly spaced values between 1 and 10 on a log scale.
(e) An array of 10 random numbers between 1 and 100. The arrays are printed to display the results.
This document describes a Python program that uses the NumPy library to create various arrays. It creates:
(a) An array of numbers from 1 to 20 in reverse order.
(b) A 2D array of size 3x4 with all elements equal to 8.
(c) An array of 10 evenly spaced values between 1 and 5.
(d) An array of 10 evenly spaced values between 1 and 10 on a log scale.
(e) An array of 10 random numbers between 1 and 100. The arrays are printed to display the results.
Name : Priyansh Jain Enrollment No : 210090107120 Class : III-A Batch - A3 Dataset Used : Online Retail 2 Dataset description : A real online retail transaction data set of two years.
Implement a program to create array with following data using NumPy module:
a. Array of numbers from 1 to 20 in reverse order
b. 2D array of size (3,4) with all elements filled with 8. c. Array of 10 values which is evenly spaced in the range of 1 to 5 d. Array of 10 values which is evenly spaced in the range of 1 to 5 but on log scale e. Array of 10 random numbers in the range of 1 to 100
In [ ]: import numpy as np
# a. Array of numbers from 1 to 20 in reverse order
array_a = np.arange(20, 0, -1)
# b. 2D array of size (3,4) with all elements filled with 8
array_b = np.full((3, 4), 8)
# c. Array of 10 values which is evenly spaced in the range of 1 to 5
array_c = np.linspace(1, 5, 10)
# d. Array of 10 values which is evenly spaced in the range of 1 to 5 but on a l
array_d = np.logspace(0, 1, 10)
# e. Array of 10 random numbers in the range of 1 to 100
array_e = np.random.randint(1, 101, 10)
# Display the arrays
print("a. Array from 1 to 20 in reverse order:\n", array_a) print("\nb. 2D array (3x4) with all elements as 8:\n", array_b) print("\nc. Array of 10 evenly spaced values between 1 and 5:\n", array_c) print("\nd. Array of 10 evenly spaced values between 1 and 10 on a log scale:\n" print("\ne. Array of 10 random numbers between 1 and 100:\n", array_e)