Ask Question
29 November, 20:41

We want to build a fence, but need to weigh the balance between the number of poles and the number of fence segments that we have to buy. Write a function called FenceCalculator, that takes two scalar Inputs: L, the length of a fence needed and S, the length of one segment of fencing. Outputs: the number of fence segments needed and the number of poles to go with it. Note: that a segment can be cut shorter, but not longer. For example, to build a 75 m long straight fence using 10 m segments, we need 8 segments. prob09 [needed segments, needed poles]

+4
Answers (1)
  1. 29 November, 23:23
    0
    def FenceCalculator (L, S):

    m = L % S

    if m = = 0:

    segment = int (L/S)

    elif m < S:

    segment = int (L/S) + 1

    print (segment)

    Explanation:

    * The code is in Python

    - Create a function FenceCalculator () that takes the length of a fence - L, and the length of one segment of a fence - S, as a parameter

    - Get the module of the L respect to S

    - If the module is equal to 0, then the segment amount is equal to the integer value of L/S

    - If the module is smaller than S, then the segment amount is equal to the integer value of L/S + 1

    - Print the segment
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “We want to build a fence, but need to weigh the balance between the number of poles and the number of fence segments that we have to buy. ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers