Answer to Question #293987 in Python for Mahesh

Question #293987

I = P*N*R . The total amount to repay will be A = P + I

Input Commands

There are 3 input commands LOAN, PAYMENT, BALANCE

LOAN

Format - LOAN BANK_NAME BORROWER_NAME PRINCIPAL NO_OF_YEARS RATE_OF_INTEREST

Example- LOAN IDIDI Dale 10000 5 4 means a loan amount of 10000 is paid to Dale by IDIDI for a tenure of 5 years at 4% rate of interest.

PAYMENT

Format - PAYMENT BANK_NAME BORROWER_NAME LUMP_SUM_AMOUNT EMI_NO

BALANCE

Input format - BALANCE BANK_NAME BORROWER_NAME EMI_NO

Output format - BANK_NAME BORROWER_NAME AMOUNT_PAID NO_OF_EMIS_LEFT


Assumptions

1. Repayments will be paid every month as EMIs until the total amount is recovered.

2. Lump sum amounts can be paid at any point of time before the end of tenure.

3. The EMI amount will be always ceiled to the nearest integer.

INPUT:

LOAN IDIDI Dale 10000 5 4

LOAN MBI Harry 2000 2 2

BALANCE IDIDI Dale 5

BALANCE IDIDI Dale 40

BALANCE MBI Harry 12

BALANCE MBI Harry 0

OUTPUT:

IDIDI Dale 1000 55

IDIDI Dale 8000 20

MBI Harry 1044 12

MBI Harry 0 24




1
Expert's answer
2022-02-05T06:01:16-0500
def balance(loans):
    # Enter data like that: IDIDI Dale 5
    name_b, name, EMI = input().split()
    paid_EMI = (loans[name_b]['P']*loans[name_b]['N']*loans[name_b]['R']+
                loans[name_b]['P'])*int(EMI)/(loans[name_b]['N']*12)
    left_EMI = loans[name_b]['N']*12 - int(EMI)
    print(name_b, loans[name_b]['name'], int(paid_EMI), left_EMI)

def main():
    loans = {
        'IDIDI':{
            'name': 'Dale',
            'P': 10000,
            'N': 5,
            'R': 0.04
        },
        'MBI': {
            'name': 'Harry',
            'P': 2000,
            'N': 2,
            'R': 0.02
        }
    }
    balance(loans)

if __name__ == '__main__':
    main()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS