Ask Question
17 July, 22:14

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]

+5
Answers (1)
  1. 17 July, 22:43
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers