Python programming exercises
Question 2. [10] You work for a company manufactures heat pipes in various sizes. Heat pipes are meant to conduct heat away from other industrial components that do not like to be hot - the higher a heat pipe's conductivity, the better. Heat pipes are manufactured by pouring molten metal into moulds. Your division is developing new heat pipes out of alloys of Aluminium and Beryllium. Alu- minium and Beryllium is sourced from the respective refineries in 1 unit cubes. Through ex- perimentation, the company metallurgist has determined that a heat pipe manufactured out of a units of Aluminium and b units of Beryllium has a conductivity given by the expression 1010 - (a - 33)2 -2(b - 23)2. The company has various moulds for the heat pipes that it manufactures. Each mould only fits a very specific volume of metal. We would like to know the proportions of units of Aluminium and Beryllium to use for each mould so that the heat pipes produced from these moulds will have the highest possible conductivity. Question 2.1. Implement a Python3 function according to the the specification below. Use your implementa- tion to determine the conductivity of a heat pipe manufactured out of 100 units Aluminium and 50 units Beryllium. Specification : Specification : Name: conductivity Input Parameters : a, b: and non-negative numbers Return : The conductivity of a heat pipe manufactured out of a units of Aluminium and b units of Beryllium. i. e. the value: 1010 - (a -33)2 -2(b - 23)2 Question 2.2. Implement a Python3 function according to the the following specification that determines, by brute force, the number units of Aluminium and Beryllium that should be used in a mould of volume v so as to maximize its conductivity. Do this by going through all possible combinations of numbers a E {0, 1, 2, 3, . .., 15700} and b E {0, 1, 2, 3, ..., 15700} in a nested for-loop. Specification : Name : best_conductivity Input Parameters : v: a non-negative integer Return : A pair of non-negative integers (a, b) satisfying: (1) a+b= v, and (2) the conductivity of the heat pipe constructed out of a units of Aluminium and b units of Beryllium is the highest possible. Question 2.3. Use your implemented function to determine, for moulds of respective volumes 56 units, 179 units, and 589 units, how many units of each metal should be used so that heat pipes manufactured out of these moulds will have the highest possible conductivity. Question 2.4. The company also has a very large mould of volume 15700 units. Try to use your function to determine how many units of each metal should be used so that heat pipes manufactured out of this large mould will have the highest possible conductivity. This is unlikely to work well and will take a long time - do hit the stop button. Why does this take so long? How many combinations (a, b) are considered when considering every combination of values of a E {0, 1, 2, 3, ..., 15700} and be {0, 1, 2, 3, .. ., 15700} in a nested for-loop? Question 2.5. Optional. Bonus question worth 2 bonus marks on top of the total. Can you think of how to adapt your implementation of best_conductivity to be more efficient by considerably cutting down the number of combinations that are considered? Give your improved implementation and explain you reasoning. Make sure your improved implementation still gives the same answers as above. This question is somewhat advanced, but is quite typical of what is expected of graduates in the workplace. To answer this question requires full understanding the problem at hand, and a small bit of thought. The teaching team will not give any hints on this