1. Convert a whole array
Write code Easy ✓ CompletedWrite a function to_fahrenheit(celsius) that takes a NumPy array of Celsius temperatures and returns a new NumPy array in Fahrenheit, using F = C * 9 / 5 + 32. Do it without a loop — let NumPy apply the formula to every value.
import numpy as np
week = np.array([10.0, 15.5, 20.0, 25.0])
def to_fahrenheit(celsius):
# return a new array (no loop needed)
pass
print(to_fahrenheit(week))import numpy as np
week = np.array([10.0, 15.5, 20.0, 25.0])
def to_fahrenheit(celsius):
return celsius * 9 / 5 + 32
print(to_fahrenheit(week))