..

Applying Knowledge - Class 7

Create a Python function named paymentValue to determine the amount due for a bill, including any applicable late fees.

The function paymentValue that you will create takes two parameters: the original bill amount and the number of days the payment is overdue. It then calculates and returns the payment amount due. The calculation is done as follows:

  • If there are no days overdue, the full bill amount is due.
  • If there are days overdue, a fine of three percent of the bill amount is added, along with a daily interest of 0.1 percent for each day of delay.

Below is the main function def main() that you will use, which prompts the user for the bill amount and the number of days overdue, and then displays the result returned by your paymentValue function.

def main():
    value = float(input())
    days = int(input())
    print(paymentValue(value, days))
main()

Input:

  1. The value of the bill.
  2. The number of days overdue.

Output:

  • The amount due for payment.

Sample Inputs/Outputs:

foo@bar:~$ py baz.py
1000
5
1035.0
foo@bar:~$
foo@bar:~$ py baz.py
635.50
0
635.5
foo@bar:~$

SOLUTION:

def valorPagamento(x, y):
	if y < 1:
		return x
	fine = x * 0.03
	fees = (x * 0.001) * y
	total = x + fine + fees
	return total

def main():
	valor = float(input())
	dias = int(input())
	print(valorPagamento(valor,dias))
main()