Write a functional for finding the amount of daily pay P in the following situation. A bus driver gets paid one hundred dollars each day plus twenty cent per kilometer k

1 answer

Function name: calculateTotalPay

Input parameters:
- k: the number of kilometers driven by the bus driver (integer or float)

Output:
- P: the total pay for the day (float)

Function:
```
def calculateTotalPay(k):
# Calculate the base pay
basePay = 100

# Calculate the additional pay based on the distance travelled
additionalPay = float(k) * 0.2

# Calculate the total pay
totalPay = basePay + additionalPay

return totalPay
```

Explanation:
- The function takes in the number of kilometers driven as input.
- The base pay is set to $100 per day.
- The additional pay is calculated by multiplying the number of kilometers driven by $0.2 per kilometer.
- The total pay is calculated by adding the base pay and additional pay.
- The total pay is returned as output.