SlideShare a Scribd company logo
# TODO 1: Define the constants as instructed in the writeup and assign them
# the correct values.
INITIAL_PRINCIPAL = 10000.0
YEARS = 5
ACCOUNT_RATE_1 = 0.027
ACCOUNT_RATE_2 = 0.0268
ACCOUNT_RATE_3 = 0.0266
ACCOUNT_CMP_FREQ_1 = 1
ACCOUNT_CMP_FREQ_2 = 12
ACCOUNT_CMP_FREQ_3 = 365
# TODO 2: Implement the `amount_after_n_years` function.
def amount_after_n_years(init_principal, acc_rate, acc_cmp_freq, years):
n = acc_cmp_freq
r = acc_rate
t = years
A = init_principal * (1 + r/n)**(n*t)
return A
# TODO 3: Define the 3 `amount_*` variables and assign them the values as
# instructed in the writeup.
c1 = 10000 * (1 + 0.027) ** 5
c2 = 10000 * (1 + 0.0268 / 12) ** (5 * 12)
c3 = 10000 * (1 + 0.0266 / 365) ** (5 * 365)
def main():
print(c1, c2, c3)
print(max(c1, c2, c3))
amount_1 = amount_after_n_years(INITIAL_PRINCIPAL, ACCOUNT_RATE_1,
ACCOUNT_CMP_FREQ_1, YEARS)
amount_2 = amount_after_n_years(INITIAL_PRINCIPAL, ACCOUNT_RATE_2,
ACCOUNT_CMP_FREQ_2, YEARS)
amount_3 = amount_after_n_years(INITIAL_PRINCIPAL, ACCOUNT_RATE_3,
ACCOUNT_CMP_FREQ_3, YEARS)
if __name__ == "__main__":
# TODO 4: Follow the instructions in the writeup to comment out the two
# print statements and uncomment the remaining lines of the code
# block.
main()
# print(f"Account option 1 will hold ${amount_1:,.2f}.")
# print(f"Account option 2 will hold ${amount_2:,.2f}.")
# print(f"Account option 3 will hold ${amount_3:,.2f}.")
# print(f"The maximum amount that can be reached is "
# f"${max(amount_1, amount_2, amount_3):,.2f}.")
print("After {} years, the initial principal of {:.2f} in account 1 with an interest rate of {}
compounded {} times per year would grow to {:.2f}.".format(YEARS, INITIAL_PRINCIPAL,
ACCOUNT_RATE_1, ACCOUNT_CMP_FREQ_1, amount_1))
print("After {} years, the initial principal of {:.2f} in account 2 with an interest rate of {}
compounded {} times per year would grow to {:.2f}.".format(YEARS, INITIAL_PRINCIPAL,
ACCOUNT_RATE_2, ACCOUNT_CMP_FREQ_2, amount_2))
print("After {} years, the initial principal of {:.2f} in account 3 with an interest rate of {}
compounded {} times per year would grow to {:.2f}.".format(YEARS, INITIAL_PRINCIPAL,
ACCOUNT_RATE_3, ACCOUNT_CMP_FREQ_3, amount_3))
Submission log file:
[ERROR] 2023-02-25 GMT-0500 08:21:50.778: An unexpected error has occurred.
Traceback (most recent call last):
File "<string>", line 74, in run
File "<string>", line 31, in generate_submission_archive
File "<string>", line 51, in __list_files_for_submission
File "<string>", line 65, in __generate_task_specific_files
File "<string>", line 138, in task3
File "<string>", line 24, in silent_import
File "<string>", line 22, in silent_import
File "C:Program
FilesWindowsAppsPythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0
libimportlib__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:UsersbwilliamsonDesktopCSCppp-p1-types-variables-functionstask3a.py", line 40,
in <module>
table_volume = table_vol(TABLE_TOP_LENGTH, TABLE_TOP_WIDTH,
TABLE_TOP_HEIGHT, TABLE_LEG_BASE_RADIUS, TABLE_LEG_HEIGHT)
File "C:UsersbwilliamsonDesktopCSCppp-p1-types-variables-functionstask3a.py", line 33,
in table_vol
leg_vol = cylinder_vol(leg_base_rad, leg_height)
File "C:UsersbwilliamsonDesktopCSCppp-p1-types-variables-functionstask3a.py", line 23,
in cylinder_vol
return 3.14.pi * base_radius ** 2 * height
AttributeError: 'float' object has no attribute 'pi'
[INFO] 2023-02-25 GMT-0500 08:21:50.781: Finding files for cleanup.
[INFO] 2023-02-25 GMT-0500 08:21:50.782: Cleanup finished.
[INFO] 2023-02-25 GMT-0500 08:21:50.782: Submission process FINISHED.
Your task is to, one last time, modify the code above so that it is more explicit and
understandable. There is one file used in this task - . You will be making changes to this file.
Start your work by opening the file in your Visual Studio Code. Find the line in the . To
complete assign the following constants with the values as indicated. - First, define 2 constants
for the initial principal that is deposited to the account and the number of years it will be kept
there. Name the constants INITIAL_PRINCIPAL and YEARS respectively. Assign them with
the values of 10000.0 and 5 . - Define 3 constants for the interest rates associated with each
account with the following names: ACCOUNT_RATE_1, ACCOUNT_RATE_2, and
ACCOUNT_RATE_3. Assign them with the following values: 0.027 , 0.0268 , and 0.0266 . -
Define 3 constants for the yearly compounding frequency with the following names:
ACCOUNT_CMP_FREQ_1, ACCOUNT_CMP_FREQ_2, and ACCOUNT_CMP_FREQ_3.
Assign them with the following values: 1, 12, and 365 . In TODO 2, you will implement the
amount_after_n_years function with the init_principal, acc_rate, acc_cmp_freq, and years
parameters. The function returns the amount that is going to be on the account after the specified
number of years based on the provided parameters. You will be using the following formula: A =
P ( 1 + n r ) n t - A : final amount - P: initial principal balance - r :interest rate - n : number of
times interest applied per time period ( acc_cmp_freq) - t : number of time period elapsed For
more details, please, refer to this tutorial. In TODO 3 , you will define - amount_3 variables ( 3
altogether) and assign each with the value returned by the amount_after_n_years. For each
variable, the amount_after_n_years function call needs to be provided with the matching
arguments from constants defined in TODO 1. For example, the correct assignment to the
amount_1 variable looks like this: [ begin{array}{l} text { amount_1 = amount_after_n_years
(INITIAL_PRINCIPAL, ACCOUNT_RATE_1, }  text { ACCOUNT_CMP_FREQ_1,
YEARS) } end{array} ] Finally, in TODO 4 , replace the existing print statements with the
more informative ones that are currently commented out, i.e. marked with the # prefix. You are
required to go about this by commenting out the original two print statements by adding # at the
beginning.. Then, uncomment the 5 lines that are originally commented out by removing "#" at
the beginning. Note that you cannot just delete the two original print statements - that would
result in you not obtaining the full score for this activity.

More Related Content

Similar to # TODO 1- Define the constants as instructed in the writeup and assign.pdf

I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdf
pnaran46
 
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docxMSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
gilpinleeanna
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
Hattori Sidek
 
Please be advised that there are four (4) programs just like this on.docx
Please be advised that there are four (4) programs just like this on.docxPlease be advised that there are four (4) programs just like this on.docx
Please be advised that there are four (4) programs just like this on.docx
lorindajamieson
 
Chapter 16 Inference for RegressionClimate ChangeThe .docx
Chapter 16 Inference for RegressionClimate ChangeThe .docxChapter 16 Inference for RegressionClimate ChangeThe .docx
Chapter 16 Inference for RegressionClimate ChangeThe .docx
keturahhazelhurst
 
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx
gilbertkpeters11344
 
Please distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfPlease distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdf
neerajsachdeva33
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
IIUM
 

Similar to # TODO 1- Define the constants as instructed in the writeup and assign.pdf (19)

Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
 
Lecture_Activities_4.1_to_4.7.pdf.pdf
Lecture_Activities_4.1_to_4.7.pdf.pdfLecture_Activities_4.1_to_4.7.pdf.pdf
Lecture_Activities_4.1_to_4.7.pdf.pdf
 
c++ exp 1 Suraj...pdf
c++ exp 1 Suraj...pdfc++ exp 1 Suraj...pdf
c++ exp 1 Suraj...pdf
 
Savitch ch 02
Savitch ch 02Savitch ch 02
Savitch ch 02
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdf
 
Data manipulation on r
Data manipulation on rData manipulation on r
Data manipulation on r
 
Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency Analysis
 
Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency Analysis
 
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docxMSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
Visual Basic Review - ICA
Visual Basic Review - ICAVisual Basic Review - ICA
Visual Basic Review - ICA
 
C++ chapter 2
C++ chapter 2C++ chapter 2
C++ chapter 2
 
Please be advised that there are four (4) programs just like this on.docx
Please be advised that there are four (4) programs just like this on.docxPlease be advised that there are four (4) programs just like this on.docx
Please be advised that there are four (4) programs just like this on.docx
 
Bis 311 final examination answers
Bis 311 final examination answersBis 311 final examination answers
Bis 311 final examination answers
 
Chapter 16 Inference for RegressionClimate ChangeThe .docx
Chapter 16 Inference for RegressionClimate ChangeThe .docxChapter 16 Inference for RegressionClimate ChangeThe .docx
Chapter 16 Inference for RegressionClimate ChangeThe .docx
 
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx
 
Compilers
CompilersCompilers
Compilers
 
Please distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfPlease distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdf
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 

More from NeiltrjGreenez

- Unpovecied anal indercoarse P Poriable digital a aristant 5 HW infec.pdf
- Unpovecied anal indercoarse P Poriable digital a aristant 5 HW infec.pdf- Unpovecied anal indercoarse P Poriable digital a aristant 5 HW infec.pdf
- Unpovecied anal indercoarse P Poriable digital a aristant 5 HW infec.pdf
NeiltrjGreenez
 
(rather than herbaceous) in that the sylem often displays secondary gr.pdf
(rather than herbaceous) in that the sylem often displays secondary gr.pdf(rather than herbaceous) in that the sylem often displays secondary gr.pdf
(rather than herbaceous) in that the sylem often displays secondary gr.pdf
NeiltrjGreenez
 
(In java) Create a method to delete a node at a particular position i.pdf
(In java)  Create a method to delete a node at a particular position i.pdf(In java)  Create a method to delete a node at a particular position i.pdf
(In java) Create a method to delete a node at a particular position i.pdf
NeiltrjGreenez
 

More from NeiltrjGreenez (20)

- Unpovecied anal indercoarse P Poriable digital a aristant 5 HW infec.pdf
- Unpovecied anal indercoarse P Poriable digital a aristant 5 HW infec.pdf- Unpovecied anal indercoarse P Poriable digital a aristant 5 HW infec.pdf
- Unpovecied anal indercoarse P Poriable digital a aristant 5 HW infec.pdf
 
(42) How does a monopoly maintain its monopoly 433- What is a natural.pdf
(42) How does a monopoly maintain its monopoly 433- What is a natural.pdf(42) How does a monopoly maintain its monopoly 433- What is a natural.pdf
(42) How does a monopoly maintain its monopoly 433- What is a natural.pdf
 
(1) What is technology and how does it relate to a firm's PPF (or its.pdf
(1) What is technology and how does it relate to a firm's PPF (or its.pdf(1) What is technology and how does it relate to a firm's PPF (or its.pdf
(1) What is technology and how does it relate to a firm's PPF (or its.pdf
 
- Simulate the circuit of the Hexadecimal to 7-segment display decoder.pdf
- Simulate the circuit of the Hexadecimal to 7-segment display decoder.pdf- Simulate the circuit of the Hexadecimal to 7-segment display decoder.pdf
- Simulate the circuit of the Hexadecimal to 7-segment display decoder.pdf
 
- Study the sample financial statements document uploaded on Canvas- N.pdf
- Study the sample financial statements document uploaded on Canvas- N.pdf- Study the sample financial statements document uploaded on Canvas- N.pdf
- Study the sample financial statements document uploaded on Canvas- N.pdf
 
#include -sys-types-h- #include -stdio-h- #include -unistd-h- #define.pdf
#include -sys-types-h- #include -stdio-h- #include -unistd-h- #define.pdf#include -sys-types-h- #include -stdio-h- #include -unistd-h- #define.pdf
#include -sys-types-h- #include -stdio-h- #include -unistd-h- #define.pdf
 
- 1- T or F-Current liabilities are separated from long term liabiliti.pdf
- 1- T or F-Current liabilities are separated from long term liabiliti.pdf- 1- T or F-Current liabilities are separated from long term liabiliti.pdf
- 1- T or F-Current liabilities are separated from long term liabiliti.pdf
 
(Stock dividends) In the spring of 2016- the CFO of HTPL Distributing.pdf
(Stock dividends) In the spring of 2016- the CFO of HTPL Distributing.pdf(Stock dividends) In the spring of 2016- the CFO of HTPL Distributing.pdf
(Stock dividends) In the spring of 2016- the CFO of HTPL Distributing.pdf
 
(This task uses Strings-) A program that prompts the user for their pa.pdf
(This task uses Strings-) A program that prompts the user for their pa.pdf(This task uses Strings-) A program that prompts the user for their pa.pdf
(This task uses Strings-) A program that prompts the user for their pa.pdf
 
(rather than herbaceous) in that the sylem often displays secondary gr.pdf
(rather than herbaceous) in that the sylem often displays secondary gr.pdf(rather than herbaceous) in that the sylem often displays secondary gr.pdf
(rather than herbaceous) in that the sylem often displays secondary gr.pdf
 
(Python) A variable defined inside a function is a local variable- oth.pdf
(Python) A variable defined inside a function is a local variable- oth.pdf(Python) A variable defined inside a function is a local variable- oth.pdf
(Python) A variable defined inside a function is a local variable- oth.pdf
 
(Python) Create a function that can take in either a list or a diction.pdf
(Python) Create a function that can take in either a list or a diction.pdf(Python) Create a function that can take in either a list or a diction.pdf
(Python) Create a function that can take in either a list or a diction.pdf
 
(Python) Create a function that prints the number of Keys and Values.pdf
(Python)  Create a function that prints the number of Keys and Values.pdf(Python)  Create a function that prints the number of Keys and Values.pdf
(Python) Create a function that prints the number of Keys and Values.pdf
 
(Pskip)-skip.pdf
(Pskip)-skip.pdf(Pskip)-skip.pdf
(Pskip)-skip.pdf
 
(In C++) In a linked list containing student names (string) and their.pdf
(In C++) In a linked list containing student names (string) and their.pdf(In C++) In a linked list containing student names (string) and their.pdf
(In C++) In a linked list containing student names (string) and their.pdf
 
(Multiple answers) Choose all of the following that are considered ris.pdf
(Multiple answers) Choose all of the following that are considered ris.pdf(Multiple answers) Choose all of the following that are considered ris.pdf
(Multiple answers) Choose all of the following that are considered ris.pdf
 
(Multiple answers) Choose all that are risk factors for CVD- HTN famil.pdf
(Multiple answers) Choose all that are risk factors for CVD- HTN famil.pdf(Multiple answers) Choose all that are risk factors for CVD- HTN famil.pdf
(Multiple answers) Choose all that are risk factors for CVD- HTN famil.pdf
 
(ii) There were 500 insects in the total population- In this populatio.pdf
(ii) There were 500 insects in the total population- In this populatio.pdf(ii) There were 500 insects in the total population- In this populatio.pdf
(ii) There were 500 insects in the total population- In this populatio.pdf
 
(i) When the savings rate is 1-3- what is the fiscal multiplier (you c.pdf
(i) When the savings rate is 1-3- what is the fiscal multiplier (you c.pdf(i) When the savings rate is 1-3- what is the fiscal multiplier (you c.pdf
(i) When the savings rate is 1-3- what is the fiscal multiplier (you c.pdf
 
(In java) Create a method to delete a node at a particular position i.pdf
(In java)  Create a method to delete a node at a particular position i.pdf(In java)  Create a method to delete a node at a particular position i.pdf
(In java) Create a method to delete a node at a particular position i.pdf
 

Recently uploaded

The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdfTelling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 

# TODO 1- Define the constants as instructed in the writeup and assign.pdf

  • 1. # TODO 1: Define the constants as instructed in the writeup and assign them # the correct values. INITIAL_PRINCIPAL = 10000.0 YEARS = 5 ACCOUNT_RATE_1 = 0.027 ACCOUNT_RATE_2 = 0.0268 ACCOUNT_RATE_3 = 0.0266 ACCOUNT_CMP_FREQ_1 = 1 ACCOUNT_CMP_FREQ_2 = 12 ACCOUNT_CMP_FREQ_3 = 365 # TODO 2: Implement the `amount_after_n_years` function. def amount_after_n_years(init_principal, acc_rate, acc_cmp_freq, years): n = acc_cmp_freq r = acc_rate t = years A = init_principal * (1 + r/n)**(n*t) return A # TODO 3: Define the 3 `amount_*` variables and assign them the values as # instructed in the writeup. c1 = 10000 * (1 + 0.027) ** 5 c2 = 10000 * (1 + 0.0268 / 12) ** (5 * 12) c3 = 10000 * (1 + 0.0266 / 365) ** (5 * 365)
  • 2. def main(): print(c1, c2, c3) print(max(c1, c2, c3)) amount_1 = amount_after_n_years(INITIAL_PRINCIPAL, ACCOUNT_RATE_1, ACCOUNT_CMP_FREQ_1, YEARS) amount_2 = amount_after_n_years(INITIAL_PRINCIPAL, ACCOUNT_RATE_2, ACCOUNT_CMP_FREQ_2, YEARS) amount_3 = amount_after_n_years(INITIAL_PRINCIPAL, ACCOUNT_RATE_3, ACCOUNT_CMP_FREQ_3, YEARS) if __name__ == "__main__": # TODO 4: Follow the instructions in the writeup to comment out the two # print statements and uncomment the remaining lines of the code # block. main() # print(f"Account option 1 will hold ${amount_1:,.2f}.") # print(f"Account option 2 will hold ${amount_2:,.2f}.") # print(f"Account option 3 will hold ${amount_3:,.2f}.") # print(f"The maximum amount that can be reached is " # f"${max(amount_1, amount_2, amount_3):,.2f}.") print("After {} years, the initial principal of {:.2f} in account 1 with an interest rate of {} compounded {} times per year would grow to {:.2f}.".format(YEARS, INITIAL_PRINCIPAL, ACCOUNT_RATE_1, ACCOUNT_CMP_FREQ_1, amount_1)) print("After {} years, the initial principal of {:.2f} in account 2 with an interest rate of {} compounded {} times per year would grow to {:.2f}.".format(YEARS, INITIAL_PRINCIPAL, ACCOUNT_RATE_2, ACCOUNT_CMP_FREQ_2, amount_2))
  • 3. print("After {} years, the initial principal of {:.2f} in account 3 with an interest rate of {} compounded {} times per year would grow to {:.2f}.".format(YEARS, INITIAL_PRINCIPAL, ACCOUNT_RATE_3, ACCOUNT_CMP_FREQ_3, amount_3)) Submission log file: [ERROR] 2023-02-25 GMT-0500 08:21:50.778: An unexpected error has occurred. Traceback (most recent call last): File "<string>", line 74, in run File "<string>", line 31, in generate_submission_archive File "<string>", line 51, in __list_files_for_submission File "<string>", line 65, in __generate_task_specific_files File "<string>", line 138, in task3 File "<string>", line 24, in silent_import File "<string>", line 22, in silent_import File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0 libimportlib__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "C:UsersbwilliamsonDesktopCSCppp-p1-types-variables-functionstask3a.py", line 40, in <module>
  • 4. table_volume = table_vol(TABLE_TOP_LENGTH, TABLE_TOP_WIDTH, TABLE_TOP_HEIGHT, TABLE_LEG_BASE_RADIUS, TABLE_LEG_HEIGHT) File "C:UsersbwilliamsonDesktopCSCppp-p1-types-variables-functionstask3a.py", line 33, in table_vol leg_vol = cylinder_vol(leg_base_rad, leg_height) File "C:UsersbwilliamsonDesktopCSCppp-p1-types-variables-functionstask3a.py", line 23, in cylinder_vol return 3.14.pi * base_radius ** 2 * height AttributeError: 'float' object has no attribute 'pi' [INFO] 2023-02-25 GMT-0500 08:21:50.781: Finding files for cleanup. [INFO] 2023-02-25 GMT-0500 08:21:50.782: Cleanup finished. [INFO] 2023-02-25 GMT-0500 08:21:50.782: Submission process FINISHED. Your task is to, one last time, modify the code above so that it is more explicit and understandable. There is one file used in this task - . You will be making changes to this file. Start your work by opening the file in your Visual Studio Code. Find the line in the . To complete assign the following constants with the values as indicated. - First, define 2 constants for the initial principal that is deposited to the account and the number of years it will be kept there. Name the constants INITIAL_PRINCIPAL and YEARS respectively. Assign them with the values of 10000.0 and 5 . - Define 3 constants for the interest rates associated with each account with the following names: ACCOUNT_RATE_1, ACCOUNT_RATE_2, and ACCOUNT_RATE_3. Assign them with the following values: 0.027 , 0.0268 , and 0.0266 . - Define 3 constants for the yearly compounding frequency with the following names: ACCOUNT_CMP_FREQ_1, ACCOUNT_CMP_FREQ_2, and ACCOUNT_CMP_FREQ_3. Assign them with the following values: 1, 12, and 365 . In TODO 2, you will implement the amount_after_n_years function with the init_principal, acc_rate, acc_cmp_freq, and years parameters. The function returns the amount that is going to be on the account after the specified number of years based on the provided parameters. You will be using the following formula: A = P ( 1 + n r ) n t - A : final amount - P: initial principal balance - r :interest rate - n : number of times interest applied per time period ( acc_cmp_freq) - t : number of time period elapsed For more details, please, refer to this tutorial. In TODO 3 , you will define - amount_3 variables ( 3 altogether) and assign each with the value returned by the amount_after_n_years. For each variable, the amount_after_n_years function call needs to be provided with the matching arguments from constants defined in TODO 1. For example, the correct assignment to the amount_1 variable looks like this: [ begin{array}{l} text { amount_1 = amount_after_n_years (INITIAL_PRINCIPAL, ACCOUNT_RATE_1, } text { ACCOUNT_CMP_FREQ_1, YEARS) } end{array} ] Finally, in TODO 4 , replace the existing print statements with the more informative ones that are currently commented out, i.e. marked with the # prefix. You are
  • 5. required to go about this by commenting out the original two print statements by adding # at the beginning.. Then, uncomment the 5 lines that are originally commented out by removing "#" at the beginning. Note that you cannot just delete the two original print statements - that would result in you not obtaining the full score for this activity.