Question
Python Programming: Recursion Concepts Recursion Base and General Cases Problem Specification Raj is a Milkman who lives in the Countryside. He delivers milk to every
Python Programming: Recursion
Concepts Recursion Base and General Cases
Problem Specification Raj is a Milkman who lives in the Countryside. He delivers milk to every house in a particular area which has about 25 houses. Everyday each house requires different quantity of milk. He has only 20mL, 50mL, 70mL jars to measure. Since a jar does not have any reading other than the maximum value such as 20mL, Raj cannot measure if the amount of milk is less than the maximum of jar. Customer asks the required amount of milk only in millilitres. For instance, no jar can be used for 15mL milk or 45 ml milk. He has to use the jars minimum number times and measure the volume of milk required so that he doesnt make the customer wait for long time. If he is not able to measure exactly the requested quantity, he tells Sorry, Cannot measure the required volume. Help him find the minimum number of times the jars can be used. Get the required quantity of milk from the user and calculate the minimum number of times the jars has to be used to exactly measure the quantity required and print the result in the expected format as below. If the exact quantity cannot be measured, print Sorry !!! Cannot measured the required volume
Input The first line contains a integer input with total volume of milk required.
Examples: Input: 170 Output: Minimum number of jars used is 3 Input: 0 Output:
Minimum number of jars used is 0 Input: 271 Output: Sorry !!! Cannot measure the required volume
Design Requirements Basic Structure You should write a recursive function to get the desired output. You should use only 20,50,70 as the available jars volume. Calculate_minimun_jars(milk_amount) //milk_amount: integer amount of milk volume to be measured
DCG Strategy (Divide - Conquer - Glue) You MUST follow the DCG strategy by showing the base case and recursive case. For the recursive case, you need to apply the DCG strategy, i.e. a set of subproblems each of which has a solution and finally combining all solutions together.
-Identify base case and recursive case
Implementation Phase Using the pseudocode developed, write the Python code for your assignment. This is a two-week assignment.
Testing Phase You have given plenty example inputs with desired outputs. The output should match exactly. Build your program incrementally, carefully testing each function as you go.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started