Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Derive a function in Python called add, that takes an array and modifies it by adding 1 to all the elements. Create another function Python

Derive a function in Python called add, that takes an array and modifies it by adding 1 to all the elements. Create another function Python called add_V2, which takes an array and returns a new array containing the values of the given array provided as a parameter incremented by 1, without modifying it.

In the main part of the program, ask the user to input an array, call the function add and display the modified array. Then call the function add_V2, with the array as a parameter, and display its resulting array. Display the original array to check that it has not changed .

Both functions must support any type arrays (dimensions), even for lists that are not arrays (the inside listsare not necessarily the same size).

Examples : Input the array elements with spaces between columns. One row per line, and an empty line at the end. 1 2 3 4 5 6

The array is:

[[1, 2, 3], [4, 5, 6]]

After executing the function add, the array is:

[[2, 3, 4], [5, 6, 7]]

A new array created with add_V2:

[[3, 4, 5], [6, 7, 8]]

After executing the function add_V2, the initial array is:

[[2, 3, 4], [5, 6, 7]]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions

Question

3. Develop a case study.

Answered: 1 week ago