Write a function that receives a single list of two-element tuples when called. The function should...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function that receives a single list of two-element tuples when called. The function should calculate the sum of the two elements in each tuple in the list and build a list of the sums named sum_list (a for loop may be handy here). Finally, the function should return a sorted version (increasing order) of the sum_list list. As an example, if the function is called as function([(1,5),(9,0), (12,3), (5,4),(13,6),(1,1)]), sum_list will be [6, 9, 15, 9, 19, 2], and the returned sorted version will be [2, 6, 9, 9, 15, 19]. 1d)Write a function to ask the user for an integer number and print "ODD" or "EVEN" according to whether the number is odd or even. The code should perform this task indefinitely until the user inputs the string "END" when prompted to input a number. 1e)Consider the function fun below. Write the body of this function for it to return the value (a*b) / c + d. Ensure that the function prompts the user if c + d = 0 (divide by zero) without the code crashing. def fun(a, b, c, d): #body of the function return(x) Write a function that receives a single list of two-element tuples when called. The function should calculate the sum of the two elements in each tuple in the list and build a list of the sums named sum_list (a for loop may be handy here). Finally, the function should return a sorted version (increasing order) of the sum_list list. As an example, if the function is called as function([(1,5),(9,0), (12,3), (5,4),(13,6),(1,1)]), sum_list will be [6, 9, 15, 9, 19, 2], and the returned sorted version will be [2, 6, 9, 9, 15, 19]. 1d)Write a function to ask the user for an integer number and print "ODD" or "EVEN" according to whether the number is odd or even. The code should perform this task indefinitely until the user inputs the string "END" when prompted to input a number. 1e)Consider the function fun below. Write the body of this function for it to return the value (a*b) / c + d. Ensure that the function prompts the user if c + d = 0 (divide by zero) without the code crashing. def fun(a, b, c, d): #body of the function return(x)
Expert Answer:
Answer rating: 100% (QA)
Heres the Python function to calculate the sum of elements in each tuple build a list of sums and re... View the full answer
Related Book For
An Introduction to Management Science Quantitative Approach to Decision Making
ISBN: 978-1337406529
15th edition
Authors: David R. Anderson, Dennis J. Sweeney, Thomas A. Williams, Jeffrey D. Camm, James J. Cochran
Posted Date:
Students also viewed these programming questions
-
For certain workers, the mean wage is $7.50/hr, with a standard deviation of $0.25. If a worker is chosen at random, what is the probability that the worker's wage is between $7.25 and $7.75? Assume...
-
Your task: You are asked to write a function that applies Simulated Annealing to a Traveling Salesman Problem. That is, your function will run simulated annealing as discussed in class and report...
-
Consider the following characteristic function of a 1-flip-flop circuit with inputs X, Y. (20 points) Q(t) is the current value of the flip-flop output and Q = Q(t+1) is the next value of the...
-
Window World extended credit to customer Nile Jenkins in the amount of $130,900 for his purchase of window treatments on April 2. Terms of the sale are 2/60, n/150. The cost of the purchase to Window...
-
Determine what type of filter the network shown in fig 11.56 represents by determining the voltage transfer function. R1 R2
-
Pop Corporation paid $1,680,000 for a 30 percent interest in Son Corporation's outstanding voting stock on January 1, 2016. The book values and fair values of Son's assets and liabilities on January...
-
To the left of z = 2.56 and to the right of z = 1.25 Find the indicated area under the standard normal curve. If convenient, use technology to find the area.
-
Newlyweds Jamie Lee and Ross have had several milestones in the past year. They are newly married, recently purchased their first home, and now have twins on the way! Jamie Lee and Ross have to...
-
Need help expanding the questions below. State of Ohio's position on the ban? What legislation if any supports or opposes the ban and or tries to protect smokers in the workplace? How smoking in...
-
You have been presented with the following set of financial statements for National Property Trust, a REIT that is about to make an initial stock offering to the public. This REIT specializes in the...
-
1) The Renecke Co. is planning to replace their printing equipment with a new computerized version that will print more copies at lower cost. The cost of the new machine will be $600,000 including...
-
You need $23887 in 3 years. If you think you could earn an annual rate of 11.61%, what would be your required monthly deposit to meet your goal? Round to 2 decimal places. Include a dollar sign ($)...
-
You are planning a 30-day vacation in Malaysia in one year's time. The present charge for a luxury suite plus meals is RM760.00 per day and the RM is presently trading at RM 3.8000/$. Hence the $...
-
You have taken out a 60-month, $23,000 car loan with an APR of 4%, compounded monthly. The monthly payment on the loan is $423.58. Assume that right after you make your 50th payment, the balance of...
-
You are thinking about investing $4,635 in your friend's landscaping business. Even though you know the investment is risky and you can't be sure, you expect your investment to be worth $5,639 next...
-
In a non liquidated distribution, Drag Race distributes land with a basis of $40,000, FMV of $60,000 and subject to a $75,000 mortgage to its sole shareholder. Jake. Jake will assume the mortgage on...
-
A sample of HO solution labelled as "28 volume" has density of 265 g/L. Mark the correct option(s) representing concentration of same solution in other units: (a) MH0 = 2.5 (c) Mole fraction of HO =...
-
Uniform electric field in Figure a uniform electric field is directed out of the page within a circular region of radius R = 3.00 cm. The magnitude of the electric field is given by E = (4.50 x 10-3...
-
Preliminary plans are under way for the construction of a new stadium for a major league baseball team. City officials have questioned the number and profitability of the luxury corporate boxes...
-
Schneiders Sweet Shop specializes in homemade candies and ice cream. Schneider produces its ice cream in-house, in batches of 50 pounds. The first stage in ice cream making is the blending of...
-
The Statewide Auto Insurance Company developed the following probability distribution for automobile collision claims paid during the past year: Payment($)_____________________Probability...
-
For the CPM Calculation Exercise found on the companion website, determine the ES, EF, LS, LF, FF, and TF for each activity. Identify the activities through which the critical path runs. How many...
-
Why is the bar chart not an adequate planning and scheduling tool?
-
What are impediments to planning, both at the beginning of a project and throughout the project?
Study smarter with the SolutionInn App