Question: CODE IN PYTHON, GETTING ONLY 66 PERCENT 5 points Plot exact and inexact Fahrenheit-Celsius conversion formulas A simple rule to quickly compute the Celsius temperature

 CODE IN PYTHON, GETTING ONLY 66 PERCENT 5 points Plot exactand inexact Fahrenheit-Celsius conversion formulas A simple rule to quickly compute the

CODE IN PYTHON, GETTING ONLY 66 PERCENT

5 points Plot exact and inexact Fahrenheit-Celsius conversion formulas A simple rule to quickly compute the Celsius temperature from the Fahrenheit degrees is to subtract 30 and then divide by 2: F - 30 ca 2 Compare this curve against the exact curve C = 5 (F 32) in a plot. Let F vary between -20 and 120 with 101 points. You should include both the approximate and exact formulae, and the absolute value of their difference (the error). You will need to: plot the data using a black dashed line ( '--') for the approximate formula; a black solid line for the accurate formula; and a black dotted line (':') for the error (preserve this order!) change the plot range to match the specification above (use the plt.xlins a,b ) function, where you provide a and b) add axes labels to your plot, 'temperature / F' and 'temperature / C'. Your submission should include a plot. Make sure to import matplotlib.pyplot as plt. Use plt.plot but not plt.show in your submission. (This assignment is based on Langtangen, Exercise 5.12.) Answer* 1 import matplotlib.pyplot as plt 2 import numpy as np 3 x=np. linspace(-20,120,101); 4 y1=(5.0/9.0)*(x-30); 5 y2=(x-30)/2.0; 6 plt.plot(x,y2,'--'); 7 plt.plot(x,y1,'-k'); 8 plt.plot(x, abs(y1-y2),':k'); 9 plt.xlim(-20,120); 10 plt.xlabel("temperature / F"); 11 plt.ylabel ("temperature / C"); 12 plt.show()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!