Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1: Write a program that uses the function div_with_remainder that was defined in class. This was the function div_with_remainder: def div_w_remainder(dividend,divisor): whole = dividend//divisor

Question 1: Write a program that uses the function div_with_remainder that was defined in class. This was the function div_with_remainder:

def div_w_remainder(dividend,divisor):

whole = dividend//divisor

remainder = dividend%divisor

return(whole,remainder)

  1. Define two global variables: big_total and maximum_share and initialize both of them to 0.

  2. Write a function called share_items that takes 2 parameter arguments: a total_number_of_items, and the the number_of_people sharing the items. This function should use divide_with_remainder to figure out how much each person gets (whole) and what is left over (remainder). It also should update the 2 global variables as follows: (i) big_total should be the total of all instances of total_number_of_items; and (ii) maximum share should increase by whole if remainder is 0 and increase by whole + 1 if remainder is greater than 0. Basically big_total is the total of things that are being divided over all andmaximum_share is the largest amount that one person would receive if all participants shared the items being distributed in a mostly-fair way (some people got one extra when there was a remainder).

  3. Write a function called question_1() that calls share_items at least 3 times and shows that it works. For example, the following instance of question_1, calls share_items 3 times:

    • the first time with arguments of 10 and 4;

    • the second time with arguments of 20 and 3; and

    • the third time with arguments of 14 and 7.

  1. Then it puts big_total and maximum_share in a print statement. Here is what it looks like to call that function and for the result to print out:

>>> question_1()

The total is 44 and the maximum share is 12

>>>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The World Wide Web And Databases International Workshop Webdb 98 Valencia Spain March 27 28 1998 Selected Papers Lncs 1590

Authors: Paolo Atzeni ,Alberto Mendelzon ,Giansalvatore Mecca

1st Edition

3540658904, 978-3540658900

More Books

Students also viewed these Databases questions