Question: Python, I will include a screen shot of my code that I need help with. I am trying to figure out how to do the

Python, I will include a screen shot of my code that I need help with. I am trying to figure out how to do the following: have main be the skeleton so have main have the loop so it calls getData to just get back that input string, then have it pass that to extractValues to get a tuple then pass that to calcRatio to get the ratio then it prints that result and to have each loop print the ratio at that point instead of saving them all up in a list to meet the output requirements. I hope these requests and explinations make sense.

I just need to find a way to make this more efficaint by having main() be the skeleton on which all of the code works off of. The purpose of the code is to create a program that is broken up into the three functions and can do the following:

1. getData should take no arguments, prompt the user for two integers and return those two integers with a space between them as a string like '1 2'.

2. extractValues should be handed a string that contains two integers with a space between them and return a tuple of two actual integers (no strings).

3. calcRatios should be handed a tuple of two integers and return ratio of those two values (the first value divided by the second).

4. Write a main program that continuously calls these modules. It should call getData, pass the result of that to extractValues, then pass the result of that to calcRatios, printing the result of that. When getData returns a blank string, the program should exit.

Python, I will include a screen shot of my code that I

def getData(buff=[]): pair-input("Enter an integer pair. hit the Enter to quit: ") return pairand buff or getDataC[pair]buff) extractva ues(values, def buff=[], counter-0) : return counter != 1en(values) -1 and buff or extractValues(values, *mapCint, valu counter 1) def calcRations(pairs): return *map(Lambda x: x[0] / x[1], pairs)] def mainO: print(*cai cRations(extractvalues(getData())), sep=' ') return main) Ln: 10 Col: 17

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!