Please use python with executed tests
Posted: Mon Jun 06, 2022 5:16 pm
Please use python with executed tests
2. Transforming. Exercise Write a function transform_in_interval (vals: List[float], f: Callable, lo: float, hi: float) -> List[float]. It finds all the numbers in vals that are at least 10, and no more than hi, and transforms each such number using f. For example, def add1(x: float) -> float: return x + 1 check.expect ("add1 in [1,4]", transform_in_interval([2,4,6,0,1], add1, 1, 4), [3, 5, 2]) def square (x: float) -> float: return x**2 check.expect("square in [5,10]", transform_in_interval([2,4,6,0,1], square, 5, 10), [36])
2. Transforming. Exercise Write a function transform_in_interval (vals: List[float], f: Callable, lo: float, hi: float) -> List[float]. It finds all the numbers in vals that are at least 10, and no more than hi, and transforms each such number using f. For example, def add1(x: float) -> float: return x + 1 check.expect ("add1 in [1,4]", transform_in_interval([2,4,6,0,1], add1, 1, 4), [3, 5, 2]) def square (x: float) -> float: return x**2 check.expect("square in [5,10]", transform_in_interval([2,4,6,0,1], square, 5, 10), [36])