Hello **Programmers/Coders,** Today we are going to share ** solutions of Programming problems of HackerRank of Programming Language Python**. At Each Problem with Successful submission with

**all Test Cases Passed,**you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.

In this post, you will find the solution for **Shape and Reshape in Python-HackerRank Problem**. We are providing the **correct and tested solutions** of coding problems present on **HackerRank**. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

**Introduction To Python**

**Python **is a widely-used, interpreted, **object-oriented, and high-level programming** language with dynamic semantics, used for general-purpose programming. It was created by **Guido van Rossum**, and first released on **February 20, 1991**.

**Python **is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. It is also used to create various machine learning algorithm, and helps in Artificial Intelligence. Python is a general purpose language, meaning it can be used to create a variety of different programs and isn’t specialized for any specific problems. This versatility, along with its beginner-friendliness, has made it one of the most-used programming languages today. A survey conducted by industry analyst firm **RedMonk **found that it was the most popular programming language among developers in **2020**.

** Link for the Problem** – Shape and Reshape in Python – HackerRank Solution

Shape and Reshape in Python – HackerRank Solution

**Problem:**

Shape :

The shape tool gives a tuple of array dimensions and can be used to change the dimensions of an array.**(a). Using shape to get array dimensions**

importnumpymy__1D_array = numpy.array([1,2,3,4,5]) print my_1D_array.shape #(5,) -> 5 rows and 0 columns my__2D_array = numpy.array([[1,2],[3,4],[6,5]]) print my_2D_array.shape #(3, 2) -> 3 rows and 2 columns

**(b). Using shape to change array dimensions**

importnumpychange_array = numpy.array([1,2,3,4,5,6]) change_array.shape = (3,2) print change_array #Output [[12] [34] [56]]

**Reshape**The reshape tool gives a new shape to an array without changing its data. It creates a new array and does not modify the original array itself.

importnumpymy_array = numpy.array([1,2,3,4,5,6]) print numpy.reshape(my_array,(3,2)) #Output [[12] [34] [56]]

#### Task :

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

#### Input Format :

A single line of input containing 9 space separated integers.

#### Output Format :

Print the 3X3 NumPy array.

#### Sample Input :

123456789

#### Sample Output :

[[123] [456] [789]]

Shape and Reshape in Python – HackerRank Solution

import numpy # Shape and Reshape in Python - Hacker Rank Solution START print(numpy.array(input().split(), int).reshape(3, 3)) # Shape and Reshape in Python - Hacker Rank Solution END