SlideShare a Scribd company logo
1 of 2
Download to read offline
USE PYTHON ONLY USE DEF function. For number 68
Solution
#!/usr/bin/python
import sys
#Global variables
interest =0
montlyPayment =0
balance =0
interestPaidForMonth =0
reducOfPrincipal =0
eomBalance =0
# getInput Function definition is here
def getInput():
global interest, montlyPayment, balance;
interest = input("Enter annual rate of interest:")
montlyPayment= input(" Enter monthly payment:")
balance= input(" Enter beg. of month balance:")
interest = float(interest)
montlyPayment=float(montlyPayment)
balance=float(balance)
return;
# calculateOutput Function definition is here
def calculateOutput():
global interestPaidForMonth, reducOfPrincipal, eomBalance
interestPaidForMonth= ((balance*interest)/100)/12
reducOfPrincipal = montlyPayment-interestPaidForMonth
eomBalance = balance-reducOfPrincipal
return;
def showOutput():
print("Interest paid For the month:",round(interestPaidForMonth, 2))
print(" Reduction of principal:",round(reducOfPrincipal, 2))
print(" End of month balance:",round(eomBalance, 2))
def main():
getInput()
calculateOutput();
showOutput()
main()
#In the question the value of reduction of principal is given wrong
#Using python , call by reference is not possible

More Related Content

Similar to USE PYTHON ONLY USE DEF function. For number 68Solution#!.pdf

Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statements
CtOlaf
 
The solution is as belowEmployeeDemo.javaimport java.util.Scann.pdf
The solution is as belowEmployeeDemo.javaimport java.util.Scann.pdfThe solution is as belowEmployeeDemo.javaimport java.util.Scann.pdf
The solution is as belowEmployeeDemo.javaimport java.util.Scann.pdf
aparnatiwari291
 
Justin trimmer cop2000 5-week 2_super supermarket pay calculator
Justin trimmer cop2000 5-week 2_super supermarket pay calculatorJustin trimmer cop2000 5-week 2_super supermarket pay calculator
Justin trimmer cop2000 5-week 2_super supermarket pay calculator
Wintur
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
amrit47
 
Compute IRR and NPV in Microsoft Excel 1.IRR Function .docx
Compute IRR and NPV in Microsoft Excel 1.IRR Function .docxCompute IRR and NPV in Microsoft Excel 1.IRR Function .docx
Compute IRR and NPV in Microsoft Excel 1.IRR Function .docx
mccormicknadine86
 
Compute IRR and NPV in Microsoft Excel 1.IRR Function .docx
Compute IRR and NPV in Microsoft Excel 1.IRR Function .docxCompute IRR and NPV in Microsoft Excel 1.IRR Function .docx
Compute IRR and NPV in Microsoft Excel 1.IRR Function .docx
patricke8
 
Wii Ruby All Work And No Play Just Wont Do
Wii Ruby All Work And No Play Just Wont DoWii Ruby All Work And No Play Just Wont Do
Wii Ruby All Work And No Play Just Wont Do
LittleBIGRuby
 
I need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdfI need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdf
rajeshjangid1865
 

Similar to USE PYTHON ONLY USE DEF function. For number 68Solution#!.pdf (18)

Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statements
 
Lab sheet 1
Lab sheet 1Lab sheet 1
Lab sheet 1
 
Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8
 
The solution is as belowEmployeeDemo.javaimport java.util.Scann.pdf
The solution is as belowEmployeeDemo.javaimport java.util.Scann.pdfThe solution is as belowEmployeeDemo.javaimport java.util.Scann.pdf
The solution is as belowEmployeeDemo.javaimport java.util.Scann.pdf
 
Learning C programming - from lynxbee.com
Learning C programming - from lynxbee.comLearning C programming - from lynxbee.com
Learning C programming - from lynxbee.com
 
How to Create a l10n Payroll Structure
How to Create a l10n Payroll StructureHow to Create a l10n Payroll Structure
How to Create a l10n Payroll Structure
 
Justin trimmer cop2000 5-week 2_super supermarket pay calculator
Justin trimmer cop2000 5-week 2_super supermarket pay calculatorJustin trimmer cop2000 5-week 2_super supermarket pay calculator
Justin trimmer cop2000 5-week 2_super supermarket pay calculator
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
 
Slides13.pdf
Slides13.pdfSlides13.pdf
Slides13.pdf
 
ICP - Lecture 5
ICP - Lecture 5ICP - Lecture 5
ICP - Lecture 5
 
Lecture 14 - Scope Rules
Lecture 14 - Scope RulesLecture 14 - Scope Rules
Lecture 14 - Scope Rules
 
C語言運算式和運算子
C語言運算式和運算子C語言運算式和運算子
C語言運算式和運算子
 
Compute IRR and NPV in Microsoft Excel 1.IRR Function .docx
Compute IRR and NPV in Microsoft Excel 1.IRR Function .docxCompute IRR and NPV in Microsoft Excel 1.IRR Function .docx
Compute IRR and NPV in Microsoft Excel 1.IRR Function .docx
 
Compute IRR and NPV in Microsoft Excel 1.IRR Function .docx
Compute IRR and NPV in Microsoft Excel 1.IRR Function .docxCompute IRR and NPV in Microsoft Excel 1.IRR Function .docx
Compute IRR and NPV in Microsoft Excel 1.IRR Function .docx
 
Wii Ruby All Work And No Play Just Wont Do
Wii Ruby All Work And No Play Just Wont DoWii Ruby All Work And No Play Just Wont Do
Wii Ruby All Work And No Play Just Wont Do
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programming
 
I need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdfI need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdf
 
Programming Global variable
Programming Global variableProgramming Global variable
Programming Global variable
 

More from lohithkart

International business1. What is the current status of Pakistan in.pdf
International business1. What is the current status of Pakistan in.pdfInternational business1. What is the current status of Pakistan in.pdf
International business1. What is the current status of Pakistan in.pdf
lohithkart
 
Describe and explain how sound travels in each Solids Liquids G.pdf
Describe and explain how sound travels in each  Solids  Liquids  G.pdfDescribe and explain how sound travels in each  Solids  Liquids  G.pdf
Describe and explain how sound travels in each Solids Liquids G.pdf
lohithkart
 
5. A child’s toy oven uses an incandescent light bulb to bake cookie.pdf
5. A child’s toy oven uses an incandescent light bulb to bake cookie.pdf5. A child’s toy oven uses an incandescent light bulb to bake cookie.pdf
5. A child’s toy oven uses an incandescent light bulb to bake cookie.pdf
lohithkart
 
8. Upon reviewing former CEO Jeff Swartz’s final blog post, do you a.pdf
8. Upon reviewing former CEO Jeff Swartz’s final blog post, do you a.pdf8. Upon reviewing former CEO Jeff Swartz’s final blog post, do you a.pdf
8. Upon reviewing former CEO Jeff Swartz’s final blog post, do you a.pdf
lohithkart
 
Write a program that moves the ball in a pane. You should define a pa.pdf
Write a program that moves the ball in a pane. You should define a pa.pdfWrite a program that moves the ball in a pane. You should define a pa.pdf
Write a program that moves the ball in a pane. You should define a pa.pdf
lohithkart
 
1. Answer the following questions about OSI modela.At which layer.pdf
1. Answer the following questions about OSI modela.At which layer.pdf1. Answer the following questions about OSI modela.At which layer.pdf
1. Answer the following questions about OSI modela.At which layer.pdf
lohithkart
 
17. Of these, which represents a heterozygote a. aa b. Aa c. .pdf
17. Of these, which represents a heterozygote a. aa b. Aa c. .pdf17. Of these, which represents a heterozygote a. aa b. Aa c. .pdf
17. Of these, which represents a heterozygote a. aa b. Aa c. .pdf
lohithkart
 
The symbiotic relationship in which the symbiotic benefits from the r.pdf
The symbiotic relationship in which the symbiotic benefits from the r.pdfThe symbiotic relationship in which the symbiotic benefits from the r.pdf
The symbiotic relationship in which the symbiotic benefits from the r.pdf
lohithkart
 
What are brain ventricles. and what functions have been ascribed to t.pdf
What are brain ventricles. and what functions have been ascribed to t.pdfWhat are brain ventricles. and what functions have been ascribed to t.pdf
What are brain ventricles. and what functions have been ascribed to t.pdf
lohithkart
 

More from lohithkart (20)

International business1. What is the current status of Pakistan in.pdf
International business1. What is the current status of Pakistan in.pdfInternational business1. What is the current status of Pakistan in.pdf
International business1. What is the current status of Pakistan in.pdf
 
Imagine a polygon (not necessarily convex) with 2015 sides. Suppose .pdf
Imagine a polygon (not necessarily convex) with 2015 sides. Suppose .pdfImagine a polygon (not necessarily convex) with 2015 sides. Suppose .pdf
Imagine a polygon (not necessarily convex) with 2015 sides. Suppose .pdf
 
In 2017, Jasmine and Thomas, a married couple, had taxable income of.pdf
In 2017, Jasmine and Thomas, a married couple, had taxable income of.pdfIn 2017, Jasmine and Thomas, a married couple, had taxable income of.pdf
In 2017, Jasmine and Thomas, a married couple, had taxable income of.pdf
 
In a maternity ward, four babies become accidentally mixed up. The AB.pdf
In a maternity ward, four babies become accidentally mixed up. The AB.pdfIn a maternity ward, four babies become accidentally mixed up. The AB.pdf
In a maternity ward, four babies become accidentally mixed up. The AB.pdf
 
How has the social change driven the development of new information .pdf
How has the social change driven the development of new information .pdfHow has the social change driven the development of new information .pdf
How has the social change driven the development of new information .pdf
 
HIV protease activates waterfor a hydrolysis reactions using what ty.pdf
HIV protease activates waterfor a hydrolysis reactions using what ty.pdfHIV protease activates waterfor a hydrolysis reactions using what ty.pdf
HIV protease activates waterfor a hydrolysis reactions using what ty.pdf
 
Fair Value and Equity Methods Conceptual Questions1. What are the .pdf
Fair Value and Equity Methods Conceptual Questions1. What are the .pdfFair Value and Equity Methods Conceptual Questions1. What are the .pdf
Fair Value and Equity Methods Conceptual Questions1. What are the .pdf
 
Do larval and adult lampreys have the 5 chordate characteristics Wh.pdf
Do larval and adult lampreys have the 5 chordate characteristics  Wh.pdfDo larval and adult lampreys have the 5 chordate characteristics  Wh.pdf
Do larval and adult lampreys have the 5 chordate characteristics Wh.pdf
 
Describe and explain how sound travels in each Solids Liquids G.pdf
Describe and explain how sound travels in each  Solids  Liquids  G.pdfDescribe and explain how sound travels in each  Solids  Liquids  G.pdf
Describe and explain how sound travels in each Solids Liquids G.pdf
 
Contrast apomixis with sexual reproduction in flowering plantsSo.pdf
Contrast apomixis with sexual reproduction in flowering plantsSo.pdfContrast apomixis with sexual reproduction in flowering plantsSo.pdf
Contrast apomixis with sexual reproduction in flowering plantsSo.pdf
 
Before dawn Josh hurriedly packed some clothes for a job-interview t.pdf
Before dawn Josh hurriedly packed some clothes for a job-interview t.pdfBefore dawn Josh hurriedly packed some clothes for a job-interview t.pdf
Before dawn Josh hurriedly packed some clothes for a job-interview t.pdf
 
5. A child’s toy oven uses an incandescent light bulb to bake cookie.pdf
5. A child’s toy oven uses an incandescent light bulb to bake cookie.pdf5. A child’s toy oven uses an incandescent light bulb to bake cookie.pdf
5. A child’s toy oven uses an incandescent light bulb to bake cookie.pdf
 
8. Upon reviewing former CEO Jeff Swartz’s final blog post, do you a.pdf
8. Upon reviewing former CEO Jeff Swartz’s final blog post, do you a.pdf8. Upon reviewing former CEO Jeff Swartz’s final blog post, do you a.pdf
8. Upon reviewing former CEO Jeff Swartz’s final blog post, do you a.pdf
 
Write a program that moves the ball in a pane. You should define a pa.pdf
Write a program that moves the ball in a pane. You should define a pa.pdfWrite a program that moves the ball in a pane. You should define a pa.pdf
Write a program that moves the ball in a pane. You should define a pa.pdf
 
1. Answer the following questions about OSI modela.At which layer.pdf
1. Answer the following questions about OSI modela.At which layer.pdf1. Answer the following questions about OSI modela.At which layer.pdf
1. Answer the following questions about OSI modela.At which layer.pdf
 
17. Of these, which represents a heterozygote a. aa b. Aa c. .pdf
17. Of these, which represents a heterozygote a. aa b. Aa c. .pdf17. Of these, which represents a heterozygote a. aa b. Aa c. .pdf
17. Of these, which represents a heterozygote a. aa b. Aa c. .pdf
 
When a researcher is working with a large set of scale data, whic.pdf
When a researcher is working with a large set of scale data, whic.pdfWhen a researcher is working with a large set of scale data, whic.pdf
When a researcher is working with a large set of scale data, whic.pdf
 
Which functions of the lymphatic system are not assisted by another s.pdf
Which functions of the lymphatic system are not assisted by another s.pdfWhich functions of the lymphatic system are not assisted by another s.pdf
Which functions of the lymphatic system are not assisted by another s.pdf
 
The symbiotic relationship in which the symbiotic benefits from the r.pdf
The symbiotic relationship in which the symbiotic benefits from the r.pdfThe symbiotic relationship in which the symbiotic benefits from the r.pdf
The symbiotic relationship in which the symbiotic benefits from the r.pdf
 
What are brain ventricles. and what functions have been ascribed to t.pdf
What are brain ventricles. and what functions have been ascribed to t.pdfWhat are brain ventricles. and what functions have been ascribed to t.pdf
What are brain ventricles. and what functions have been ascribed to t.pdf
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 

Recently uploaded (20)

Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 

USE PYTHON ONLY USE DEF function. For number 68Solution#!.pdf

  • 1. USE PYTHON ONLY USE DEF function. For number 68 Solution #!/usr/bin/python import sys #Global variables interest =0 montlyPayment =0 balance =0 interestPaidForMonth =0 reducOfPrincipal =0 eomBalance =0 # getInput Function definition is here def getInput(): global interest, montlyPayment, balance; interest = input("Enter annual rate of interest:") montlyPayment= input(" Enter monthly payment:") balance= input(" Enter beg. of month balance:") interest = float(interest) montlyPayment=float(montlyPayment) balance=float(balance) return; # calculateOutput Function definition is here def calculateOutput(): global interestPaidForMonth, reducOfPrincipal, eomBalance interestPaidForMonth= ((balance*interest)/100)/12 reducOfPrincipal = montlyPayment-interestPaidForMonth eomBalance = balance-reducOfPrincipal return; def showOutput(): print("Interest paid For the month:",round(interestPaidForMonth, 2))
  • 2. print(" Reduction of principal:",round(reducOfPrincipal, 2)) print(" End of month balance:",round(eomBalance, 2)) def main(): getInput() calculateOutput(); showOutput() main() #In the question the value of reduction of principal is given wrong #Using python , call by reference is not possible