Put the lesson Introduction to Matplotlib into practice by writing a program yourself.
Over a moderate range, the resistivity of copper rises linearly with temperature: ρ = ρ₀ × (1 + α × (T − 293)), with ρ₀ = 1.72 µΩ·cm and α = 0.0039 per K.
Calculate the resistivity at six evenly spaced temperatures from 293 K to 793 K, print the values, and plot them.
np.linspace() to create 6 temperatures from 293 to 793 K.np.round().[1.72 2.39 3.06 3.73 4.4 5.07]
Write your program below and press Run. Each run is checked against the expected output.
Press Run to see what your program prints.
One possible solution. Other programs that print the same output are correct too.
import numpy as npimport matplotlib.pyplot as pltrho_0 = 1.72 # µΩ·cm at 293 Kalpha = 0.0039 # 1/Ktemperature = np.linspace(293, 793, 6)resistivity = rho_0 * (1 + alpha * (temperature - 293))print(np.round(resistivity, 2))plt.plot(temperature, resistivity, marker="o")plt.xlabel("Temperature (K)")plt.ylabel("Resistivity (µΩ·cm)")plt.title("Resistivity of copper")plt.grid(True)plt.show()