Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part A Write a function: named add_one takes 1 argument, a list returns 1 value, a list In this function, you should loop through each
Part A Write a function: named add_one takes 1 argument, a list returns 1 value, a list In this function, you should loop through each element of the argument list, add 1 to it, and then return the new list. For example, add_one([1, 2, 3]) should return [2, 3, 4] . No imports! HINT: I would highly recommend constructing a new list, rather than updating the old one. Graded Read Only : import numpy as np np.random seed (7584) list1 = np.random.randint(-100, 100, 10) actuali = listi + 1 pred1 = add_one(listi.tolist() assert set (predl) == set(actuali.tolist() : np.random. seed(68527) Read Only list2 = np.random.randint(-100, 100, 100) actual2 = list2 + 1 pred2 = add_one(list2.tolist()) assert set (pred2) == set(actual2.tolist()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started