Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this homework you will write a sapt to do some wel alolation or feed-rute mortyget. Your care should have at least the following function:

image text in transcribedimage text in transcribedimage text in transcribed

For this homework you will write a sapt to do some wel alolation or feed-rute mortyget. Your care should have at least the following function: pt nin_payment() FO Pameters . the total amount of the mortgage called the principal should be a positive number) o the annual interest rate (should be a fost between 0 and 1) o the term of the mortgage in years (should bea positive integer; default value: 30 the number of payment per year (should be a positive integer; default value: 12) Punctionality Compute the minimum mortgage payment. Should use the formula , where A is the minimum payment amount . Pis the principal amount . rathe interest rate per payment (the annual interest rate divided by the number of payments per is the total number of payments (the term of the mortgage in years the number of payment per year) Use math.ceil() to raise the minimum payment you calculated to the next highest integer, and return this integer . You will need to import math in order to do this. Remember, import statements belong at the map of your script, right after your script decstring. interest_due) Parameters the balance of the mortgage (the part of the principal that has not been paid back yet, should be positive number) the annual interest rate (should be a float between 0 and 1) the number of payments per year (should be a positive integer; default value: 12) Functionality Compute and return the amount of interest due in the next payment according to the formula is be where fis the amount of interest due in the next payment bis the balance of the mortgage is the interest rate per payment the annual interest rate divided by the number of payments per yar) remaining payments Parameters the balance of the mortgage (the part of the principal that has not been paid back yelshould be positive number) the annual interest rate should be a float between 0 and 1) the payment amount the amount then wants to should be patie number the number of payments per year should be a positive integer.detult value: 12 Functionality Compute and return the number of payments required to pay off the more. We will do this by multing payment ONE Atime until the balance of the mortgage reached RG, Mrming fixed payments (in other words, asume that each payment is the same amount of money as the previous Note that a morte payment is broken down into two parts: an interest payment and a part that pays down the balance of the mortgage. The interest payment is calculated described under interest due() the rest of the payment goes toward the balance of the morp. The percentage of the payment that pe toward interest decreases with every payment became R depends on the balance of the mortgage, which also decreases with every payment Here is an algorithm for simulating payments until the mortgage is paid of Intalie a counter with a value of my this counter represents the number of payments to be As long as the balance of the mortgage is positive, do the following Uke the interest_due() function to determine what portion of the next payment will be interest. The total payment minus interest dae is the amount that will go toward paying the balance of the principal. Remember, the amounts will change with every payment. Reduce the balance by the part of the payment that goes toward paying the balance. Increase the counter When the balance of the mortgage is no longer positive, the value of the counter is the number of payments required. Return this value. Parameters the total amount of the mortgage, the principal should be a positive number) the annual interest rate (should be a float between 0 and 1) the term of the mortgage, in years (should be a positive integer; default value ) the number of payments per year (should be a positive integer:default value: 12) o the user's target payment (the amount the user wishes to pay per payment should be a positive number or None: default value: None) . A value of None indicates that the user wishes to use the minimum payment Functionality Compute the minimum payment using the get_sin_payment function Display the minimum payment to the user If the startyment is None, set the target payment to be minimum payment If the start payment is less than the minimum payment, print a message to the user leg Your target payment is less than the minimum payment for this mortgage otherwise Uw remaining payments) to figure out the total number of payment required into the beginning of mortgage, the balance is equal to the totalm e n t Display this number to the series. Il you make payments of Stat y ou will pay the mortgage in total payments replace the angebrackets with the appropriate parse args) Parameters strings containing the command line arguments for the program when you call this program, you will pass sys.argv[1:) as the argument for this parametet Functionality Create an instance of the ArgumentParser class from the argan module the the add_argument() method of your ArgumentParser instance to add the following arguments Required argumenta (le, the we can't run the program without specifying there) the total amount of the mortgage (as a float) the annual interest rate (as a float should be between 0 and 1) Optional arguments (le, the user can choose to specify there or on them and use the default values): the term of the mortgage in years (as an integer; default value: 30) the number of payments per year (as an integer; default value: 12) the target payment amount (as a float default value: None) Uke the parse_args() method of your ArgumentParser instance to pare the list of strings that was passed to your function; this will result in a namespace object, which you should return Note You will need to importar parse and sys, or at least parts of these modules. In order for this function to work properly. Remember, import statements belong at the top of your script right after the script docstring Aher your function definitions, you should have an if __name_ do the following __main__'s statement in which you puss sys.argv[1:] to parse_args() and store the result in a variable call the main function is in the total amount of the mortgage, the annual interest rate, the term of the mortgage, the number of payments per year, and the target payment amount using the values extracted from the command line arguments by your parse_args() function Here are some examples of what it might look like when you run your code. The gray symbol represents the prompt in your terminal you shouldn't type this character. Your script and your optional command line arguments may have different names than mine, that's fine. $ python3 mortgage calculator.py 300,000 0.04 Your minimum payment is $1433. If you make payments of $1433, you will pay off the mortgage in 360 payments. $ python3 mortgage calculator.py 300_000 .04 --payment 2000 Your minimum payment is $1433. If you make payments of $2000.0, you will pay off the mortgage in 209 payments. $ python3 mortgage calculator.py 300,000 0.04 --payment 1000 Your minimum payment is $1433. Your target payment is less than the minimum payment. For this homework you will write a sapt to do some wel alolation or feed-rute mortyget. Your care should have at least the following function: pt nin_payment() FO Pameters . the total amount of the mortgage called the principal should be a positive number) o the annual interest rate (should be a fost between 0 and 1) o the term of the mortgage in years (should bea positive integer; default value: 30 the number of payment per year (should be a positive integer; default value: 12) Punctionality Compute the minimum mortgage payment. Should use the formula , where A is the minimum payment amount . Pis the principal amount . rathe interest rate per payment (the annual interest rate divided by the number of payments per is the total number of payments (the term of the mortgage in years the number of payment per year) Use math.ceil() to raise the minimum payment you calculated to the next highest integer, and return this integer . You will need to import math in order to do this. Remember, import statements belong at the map of your script, right after your script decstring. interest_due) Parameters the balance of the mortgage (the part of the principal that has not been paid back yet, should be positive number) the annual interest rate (should be a float between 0 and 1) the number of payments per year (should be a positive integer; default value: 12) Functionality Compute and return the amount of interest due in the next payment according to the formula is be where fis the amount of interest due in the next payment bis the balance of the mortgage is the interest rate per payment the annual interest rate divided by the number of payments per yar) remaining payments Parameters the balance of the mortgage (the part of the principal that has not been paid back yelshould be positive number) the annual interest rate should be a float between 0 and 1) the payment amount the amount then wants to should be patie number the number of payments per year should be a positive integer.detult value: 12 Functionality Compute and return the number of payments required to pay off the more. We will do this by multing payment ONE Atime until the balance of the mortgage reached RG, Mrming fixed payments (in other words, asume that each payment is the same amount of money as the previous Note that a morte payment is broken down into two parts: an interest payment and a part that pays down the balance of the mortgage. The interest payment is calculated described under interest due() the rest of the payment goes toward the balance of the morp. The percentage of the payment that pe toward interest decreases with every payment became R depends on the balance of the mortgage, which also decreases with every payment Here is an algorithm for simulating payments until the mortgage is paid of Intalie a counter with a value of my this counter represents the number of payments to be As long as the balance of the mortgage is positive, do the following Uke the interest_due() function to determine what portion of the next payment will be interest. The total payment minus interest dae is the amount that will go toward paying the balance of the principal. Remember, the amounts will change with every payment. Reduce the balance by the part of the payment that goes toward paying the balance. Increase the counter When the balance of the mortgage is no longer positive, the value of the counter is the number of payments required. Return this value. Parameters the total amount of the mortgage, the principal should be a positive number) the annual interest rate (should be a float between 0 and 1) the term of the mortgage, in years (should be a positive integer; default value ) the number of payments per year (should be a positive integer:default value: 12) o the user's target payment (the amount the user wishes to pay per payment should be a positive number or None: default value: None) . A value of None indicates that the user wishes to use the minimum payment Functionality Compute the minimum payment using the get_sin_payment function Display the minimum payment to the user If the startyment is None, set the target payment to be minimum payment If the start payment is less than the minimum payment, print a message to the user leg Your target payment is less than the minimum payment for this mortgage otherwise Uw remaining payments) to figure out the total number of payment required into the beginning of mortgage, the balance is equal to the totalm e n t Display this number to the series. Il you make payments of Stat y ou will pay the mortgage in total payments replace the angebrackets with the appropriate parse args) Parameters strings containing the command line arguments for the program when you call this program, you will pass sys.argv[1:) as the argument for this parametet Functionality Create an instance of the ArgumentParser class from the argan module the the add_argument() method of your ArgumentParser instance to add the following arguments Required argumenta (le, the we can't run the program without specifying there) the total amount of the mortgage (as a float) the annual interest rate (as a float should be between 0 and 1) Optional arguments (le, the user can choose to specify there or on them and use the default values): the term of the mortgage in years (as an integer; default value: 30) the number of payments per year (as an integer; default value: 12) the target payment amount (as a float default value: None) Uke the parse_args() method of your ArgumentParser instance to pare the list of strings that was passed to your function; this will result in a namespace object, which you should return Note You will need to importar parse and sys, or at least parts of these modules. In order for this function to work properly. Remember, import statements belong at the top of your script right after the script docstring Aher your function definitions, you should have an if __name_ do the following __main__'s statement in which you puss sys.argv[1:] to parse_args() and store the result in a variable call the main function is in the total amount of the mortgage, the annual interest rate, the term of the mortgage, the number of payments per year, and the target payment amount using the values extracted from the command line arguments by your parse_args() function Here are some examples of what it might look like when you run your code. The gray symbol represents the prompt in your terminal you shouldn't type this character. Your script and your optional command line arguments may have different names than mine, that's fine. $ python3 mortgage calculator.py 300,000 0.04 Your minimum payment is $1433. If you make payments of $1433, you will pay off the mortgage in 360 payments. $ python3 mortgage calculator.py 300_000 .04 --payment 2000 Your minimum payment is $1433. If you make payments of $2000.0, you will pay off the mortgage in 209 payments. $ python3 mortgage calculator.py 300,000 0.04 --payment 1000 Your minimum payment is $1433. Your target payment is less than the minimum payment

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

Discuss the five steps that can be used to conduct a task analysis

Answered: 1 week ago

Question

Discuss the purpose and advantages of conducting a needs assessment

Answered: 1 week ago