# HackerRank Python Challenges

In this article I show how I solved HackerRank Python challenges. The main purpose of the content is to present my acquired experiences primarily for learning purposes.

Other categories:

Introduction
Basic Data Types
Strings
Sets
Itertools
Collections
Built-Ins
Numpy
Others

## Numpy

### Arrays

You are given a space separated list of numbers. Your task is to print a reversed NumPy array with the element type float.

Solution:

```import numpy

def arrays(arr):
return numpy.array(arr[::-1], float)

arr = input().strip().split(' ')
result = arrays(arr)
print(result)
```

### Shape and Reshape

You are given a space separated list of nine integers. Your task is to convert this list into a 3x3 NumPy array.

Solution:

```import numpy

print(numpy.reshape(numpy.array(list(map(int, numpy.array(input().split())))), (3, 3)))
```

### Transpose and Flatten

You are given a NxM integer array matrix with space separated elements (N = rows and M = columns). Your task is to print the transpose and flatten results.

Solution:

```import numpy

n, m = input().split()

lst = []
for i in range(int(n)):
lst.append(list(map(int, input().split())))

arr = numpy.array(lst)

print(numpy.transpose(arr))
print(numpy.array(lst).flatten())
```

### Concatenate

You are given two integer arrays of size NxP and MxP (N & M are rows, and P is the column). Your task is to concatenate the arrays along axis 0.

Solution:

```import numpy

n, m, p = input().split()

lst_n = []
lst_m = []
for i in range(int(n)):
lst_n.append(list(map(int, input().split())))

for i in range(int(m)):
lst_m.append(list(map(int, input().split())))

print(numpy.concatenate((numpy.array(lst_n), numpy.array(lst_m))))
```

### Zeros and Ones

You are given the shape of the array in the form of space-separated integers, each integer representing the size of different dimensions, your task is to print an array of the given shape and integer type using the tools numpy.zeros and numpy.ones.

Solution:

```import numpy

ints = tuple(map(int, input().split()))

print(numpy.zeros(ints, dtype = int))
print(numpy.ones(ints, dtype = int))
```

### Array Mathematics

You are given two integer arrays, A and B of dimensions NxM. Your task is to perform the following operations:

2. Subtract (A - B)
3. Multiply (A * B)
4. Integer Division (A / B)
5. Mod (A % B)
6. Power (A ** B)

Solution:
```import numpy

nm = list(map(int, input().split()))
a = []
b = []

for i in range(nm):
a.append(list(map(int, input().split())))

for i in range(nm):
b.append(list(map(int, input().split())))

print(numpy.subtract(a, b))
print(numpy.multiply(a, b))
print(numpy.floor_divide(a, b))
print(numpy.mod(a, b))
print(numpy.power(a, b))
```

### Polynomials

```import numpy