... | @@ -72,34 +72,36 @@ Mayer](https://www.amazon.com/Coffee-Break-NumPy-Science-Mastery/dp/1076932614). |
... | @@ -72,34 +72,36 @@ Mayer](https://www.amazon.com/Coffee-Break-NumPy-Science-Mastery/dp/1076932614). |
|
|
|
|
|
**Creating Arrays**
|
|
**Creating Arrays**
|
|
|
|
|
|
```Python
|
|
```python
|
|
array_size = 8
|
|
array_size = 8
|
|
zeroes_array = np.zeros(array_size)
|
|
zeroes_array = np.zeros(array_size)
|
|
print(zeroes_array)
|
|
print(zeroes_array)
|
|
print()
|
|
print()
|
|
```
|
|
```
|
|
|
|
|
|
```Python
|
|
```python
|
|
array_size = 12
|
|
array_size = 12
|
|
ones_array = np.ones(array_size)
|
|
ones_array = np.ones(array_size)
|
|
print(ones_array)
|
|
print(ones_array)
|
|
print()
|
|
print()
|
|
```
|
|
```
|
|
|
|
|
|
```Python
|
|
```python
|
|
# Contents are "whatever happens to be in memory"
|
|
# Contents are "whatever happens to be in memory"
|
|
array_size = 16
|
|
array_size = 16
|
|
unitialized_array = np.empty(array_size)
|
|
unitialized_array = np.empty(array_size)
|
|
print(unitialized_array)
|
|
print(unitialized_array)
|
|
print()
|
|
print()
|
|
# Create two NumPy arrays from Python lists
|
|
```
|
|
|
|
|
|
|
|
```python
|
|
python_list = [2, 4, 8, 16, 32, 64]
|
|
python_list = [2, 4, 8, 16, 32, 64]
|
|
np_array = np.array(python_list)
|
|
np_array = np.array(python_list)
|
|
print(np_array)
|
|
print(np_array)
|
|
print()
|
|
print()
|
|
```
|
|
```
|
|
|
|
|
|
```Python
|
|
```python
|
|
python_list = [2., 4., 8., 16., 32., 64.]
|
|
python_list = [2., 4., 8., 16., 32., 64.]
|
|
np_array = np.array(python_list)
|
|
np_array = np.array(python_list)
|
|
print(np_array)
|
|
print(np_array)
|
... | | ... | |