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]

Answer :

frknkrtrn

Answer:

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

Other Questions