Question: Warning! Remember to write proper docstrings for your functions. To know what a proper docstring looks like, follow the examples in the lessons. Exercise 1

Warning! Remember to write proper docstrings for your functions. To know what a proper docstring looks like, follow the examples in the lessons. Exercise 1 a) Write a function that converts degrees Farenheit into Celsius. To convert temperature in degrees Fahrenheit to Celsius, subtract 32 and multiply by 5/9. In [ ]: def fahrenheit_celsius(temp): wuwrite docstrings here ! \# YOUR CODE HERE raise NotImplementedError() In [ ] : b) Write a function to convert a distance from miles to kilometers. (Note: 1mi=1.609344km.) In [ ]: def \( \begin{array}{l} \text { miles_} k m \text { (dist): } \\ \text { u Write docstrings here } \\ \# \text { YOUR CODE HERE } \\ \text { raise NotImplementedError() }\end{array} \) In [ ] : c) Write a new function miles_km_fix, based on miles_km, that also checks the sign of its parameter dist. If dist is negative, the function should return the string 'distance cannot be negative'. Otherwise, the function should behave like miles_ km.. In [ ] : d) Write a function that computes the distance between two 3D points. Treat the arguments of your function as numpy arrays. Do not use for statements. Tips: - Use array operations. - Remember to check numpy built-in functions; there are functions to compute the square root and the sum of the elements of an array. In [ ]: def \( \begin{array}{l} \text { distance_3D (point_a, point_b): } \\ \text { u Write docstrings here } \\ \text { \# YOUR CODE HERE } \\ \text { raise NotImplementedError() }\end{array} \) In [ ]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
