- #1
ver_mathstats
- 260
- 21
- Homework Statement
- Assign to a variable a NumPy array that has shape (3, 4) and whose entries are all equal to 0.0 (so the values of a are of type float). So, if i= 0,1,2 and j=0,1,2,3 then a[i,j]=0.0.
- Relevant Equations
- python
I feel like I have over complicated this question but here is the code I wrote out for it, I wrote it as a function but when I printed my values I realized I did not need a function to do so. So would I just use my second code to answer the question.
Or would the solution be as simple as:
Thanks.
Python:
import numpy as np
def array_zero(n):
for i in range(n):
for i in range(n):
result=print(a1[i,j])
return result
a1=np.zeros([3,4],dtype=float)
print(a1[0,0])
print(a1[2,3])
Or would the solution be as simple as:
Python:
import numpy as np
a1=np.zeros([3,4],dtype=float)
print(a1)
print()
print(a1[0,0])
Thanks.