मराठी

Create the following NumPy arrays: A 2-D array called myarray2 using arange() having 3 rows and 5 columns with start value = 4, step size 4 and dtype as float.

Advertisements
Advertisements

प्रश्न

Create the following NumPy arrays:

A 2-D array called myarray2 using arange() having 3 rows and 5 columns with start value = 4, step size 4 and dtype as float.

कोड लेखन
Advertisements

उत्तर

A 2-D NumPy array called myarray2 having 3 rows and 5 columns can be created using the arange() function with start value = 4, step size = 4, and dtype = float.

import numpy as np
myarray2 = np.arange(4, 64, 4, dtype=float).reshape(3, 5)
print(myarray2)

Output:

[4. 8. 12. 16. 20.]
[24. 28. 32. 36. 40.]
[44. 48. 52. 56. 60.]]

Thus, it myarray2 is a 2-D array with 3 rows and 5 columns, containing floating-point values.

shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 6: Introduction to NumPy - Exercise [पृष्ठ ११३]

APPEARS IN

एनसीईआरटी Informatics Practices [English] Class 11
पाठ 6 Introduction to NumPy
Exercise | Q 4. e) | पृष्ठ ११३
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×