Answer to Question #292872 in Python for suresh

Question #292872

6. Create an array with whole numbers values from 0 to 10 and find what is the command to extract the elements in the following sequence -


array ([7,4,1])




7. Create a NumPy array having user input values and convert the integer type to the float type of the elements of the array. For instance:


Original array [1, 2, 3, 4]


Array converted to a float type: [ 1. 2. 3. 4.]






8. Write a NumPy program to append values to the end of an array. For instance:


Original array: [10, 20, 30]


After append values to the end of the array:


[10 20 30 40 50 60 70 80 90]


9. Create a 2 dimensional array with 3 rows and 3 columns containing random numbers from 1 to 9. Find the difference between the maximum element across the columns and the minimum element across the rows.






10. Create a 3*3 array having values from 10-90(interval of 10) and store that in array1. Perform the following tasks:


a. Extract the 1st row from the array.


b. Extract the last element from the array.




1
Expert's answer
2022-02-01T11:15:18-0500
import numpy as np

# 6.
# n = np.arange(1, 10, 3)
# print(n)

# 7.
# lst1 = [int(item) for item in input("Enter the list items: ").split()]
# a = np.array(lst1, dtype=np.float64)
# print(a)

# 8.
# x = [10, 20, 30]
# x = np.append(x, [[40, 50, 60], [70, 80, 90]])
# print(x)

# 9.
# x = random_matrix_array = np.random.randint(1,10,size=(3,3))
# print(x)
# print(x.max() - x.min())

# 10.
x = [[30*y + 10*x for x in range(1, 4)] for y in range(3)]
x = np.squeeze(np.asarray(x))
print(x[:1])
print(x[2][2])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS