﻿ NumPy: Concatenate two given arrays of shape (2, 2) and (2,1) - w3resource # NumPy: Concatenate two given arrays of shape (2, 2) and (2,1)

## NumPy: Array Object Exercise-197 with Solution

Write a NumPy program to create to concatenate two given arrays of shape (2, 2) and (2,1).

Sample Solution:

Python Code:

``````import numpy as np
nums1 = np.array([[4.5, 3.5],
[5.1, 2.3]])
nums2 = np.array([,
])
print("Original arrays:")
print(nums1)
print(nums2)
print("\nConcatenating the said two arrays:")
print(np.concatenate((nums1, nums2), axis=1))
```
```

Sample Output:

```Original arrays:
[[4.5 3.5]
[5.1 2.3]]
[
]

Concatenating the said two arrays:
[[4.5 3.5 1. ]
[5.1 2.3 2. ]]
```

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz

﻿

## Python: Tips of the Day

Set comprehension:

```>>> m = {x ** 2 for x in range(5)}
>>> m
{0, 1, 4, 9, 16}
```