Answers for "python create an array of 1s"

3

create an array from 1 to n python

a_list = list(range(1, 5))

print(a_list)
[1,2,3,4,5]
Posted by: Guest on September-13-2020
2

python how to make an array of ones

# Basic syntax:
np.ones((number_rows, number_cols), dtype=int)

# Example usage:
import numpy as np
np.ones((5, 3), dtype=int)
array([[1, 1, 1],
       [1, 1, 1],
       [1, 1, 1],
       [1, 1, 1],
       [1, 1, 1]])

# Note, use np.zeros to create an array of zeros
Posted by: Guest on October-04-2020

Code answers related to "python create an array of 1s"

Python Answers by Framework

Browse Popular Code Answers by Language