SlideShare a Scribd company logo
1 of 1
Download to read offline
# This program will take 2 numbers from the user and
# find the hypotenuse using the Pythagorean theorem
import math
# Function to square the numbers
def squarefunction(length):
square = length * length
print "The square of a side is: ", square
return square
# end of function
# Function to calculate Pythagorean theorem
def pythagorean(aside, bside):
HypotenuseSquared = aside + bside
hypotenuse = math.sqrt(HypotenuseSquared)
print "The hypotenuse of the 2 sides is: ", hypotenuse
# end of function
# Get the length of the sides from the user
firstside = input("Enter the first side: ")
secondside = input("Enter the second side: ")
# Get the squares of 2 sides
firstsidesquared = squarefunction(firstside)
secondsidesquared = squarefunction(secondside)
# print "The firstside variable is: ", firstside
# print "The secondside variable is: ", secondside
# Put the squares into the Pythagorean function
pythagorean(firstsidesquared, secondsidesquared)

More Related Content

Similar to PythonPythagoreanTheorem

Need to revise working code below,A good design means the applicat.pdf
Need to revise working code below,A good design means the applicat.pdfNeed to revise working code below,A good design means the applicat.pdf
Need to revise working code below,A good design means the applicat.pdf
archgeetsenterprises
 
Final project report
Final project reportFinal project report
Final project report
ssuryawanshi
 
I worte the code according to the requirement.And also I wrote the c.pdf
I worte the code according to the requirement.And also I wrote the c.pdfI worte the code according to the requirement.And also I wrote the c.pdf
I worte the code according to the requirement.And also I wrote the c.pdf
sudhinjv
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
vrickens
 
C++ Course - Lesson 2
C++ Course - Lesson 2C++ Course - Lesson 2
C++ Course - Lesson 2
Mohamed Ahmed
 
can someone fix the errors in this code- the name needs to be Fraction.pdf
can someone fix the errors in this code- the name needs to be Fraction.pdfcan someone fix the errors in this code- the name needs to be Fraction.pdf
can someone fix the errors in this code- the name needs to be Fraction.pdf
vinaythemodel
 
C++ Function
C++ FunctionC++ Function
C++ Function
Hajar
 
This is Function Class public abstract class Function {    .pdf
This is Function Class public abstract class Function {    .pdfThis is Function Class public abstract class Function {    .pdf
This is Function Class public abstract class Function {    .pdf
amitbagga0808
 

Similar to PythonPythagoreanTheorem (20)

Need to revise working code below,A good design means the applicat.pdf
Need to revise working code below,A good design means the applicat.pdfNeed to revise working code below,A good design means the applicat.pdf
Need to revise working code below,A good design means the applicat.pdf
 
Import java
Import javaImport java
Import java
 
Final project report
Final project reportFinal project report
Final project report
 
Functions
FunctionsFunctions
Functions
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQL
 
Programs.doc
Programs.docPrograms.doc
Programs.doc
 
AI-Programs.pdf
AI-Programs.pdfAI-Programs.pdf
AI-Programs.pdf
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce function
 
I worte the code according to the requirement.And also I wrote the c.pdf
I worte the code according to the requirement.And also I wrote the c.pdfI worte the code according to the requirement.And also I wrote the c.pdf
I worte the code according to the requirement.And also I wrote the c.pdf
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
 
C++ Course - Lesson 2
C++ Course - Lesson 2C++ Course - Lesson 2
C++ Course - Lesson 2
 
Dealing with Python Reactively - PyCon Korea 2017
Dealing with Python Reactively - PyCon Korea 2017Dealing with Python Reactively - PyCon Korea 2017
Dealing with Python Reactively - PyCon Korea 2017
 
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
 
can someone fix the errors in this code- the name needs to be Fraction.pdf
can someone fix the errors in this code- the name needs to be Fraction.pdfcan someone fix the errors in this code- the name needs to be Fraction.pdf
can someone fix the errors in this code- the name needs to be Fraction.pdf
 
OOP.pptx
OOP.pptxOOP.pptx
OOP.pptx
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Write a Function procedure to calculate the surface area of a right ci.docx
Write a Function procedure to calculate the surface area of a right ci.docxWrite a Function procedure to calculate the surface area of a right ci.docx
Write a Function procedure to calculate the surface area of a right ci.docx
 
This is Function Class public abstract class Function {    .pdf
This is Function Class public abstract class Function {    .pdfThis is Function Class public abstract class Function {    .pdf
This is Function Class public abstract class Function {    .pdf
 

More from Matt R

EstimateExtraterrestrialLife
EstimateExtraterrestrialLifeEstimateExtraterrestrialLife
EstimateExtraterrestrialLife
Matt R
 
LinuxPresentation500kb
LinuxPresentation500kbLinuxPresentation500kb
LinuxPresentation500kb
Matt R
 
OpenBSD-pf-filter
OpenBSD-pf-filterOpenBSD-pf-filter
OpenBSD-pf-filter
Matt R
 
PythonShutdownWindows
PythonShutdownWindowsPythonShutdownWindows
PythonShutdownWindows
Matt R
 
TelephoneInfo-OpenInteraction
TelephoneInfo-OpenInteractionTelephoneInfo-OpenInteraction
TelephoneInfo-OpenInteraction
Matt R
 
PhoneCallTools
PhoneCallToolsPhoneCallTools
PhoneCallTools
Matt R
 
LaptopTrustIssues
LaptopTrustIssuesLaptopTrustIssues
LaptopTrustIssues
Matt R
 
Interactions
InteractionsInteractions
Interactions
Matt R
 
Interaction-Incident
Interaction-IncidentInteraction-Incident
Interaction-Incident
Matt R
 
FoundationProcess
FoundationProcessFoundationProcess
FoundationProcess
Matt R
 
FindStaffPerson
FindStaffPersonFindStaffPerson
FindStaffPerson
Matt R
 
ChangesChecklist
ChangesChecklistChangesChecklist
ChangesChecklist
Matt R
 
bigalsnetwork
bigalsnetworkbigalsnetwork
bigalsnetwork
Matt R
 
DateDiffQuery
DateDiffQueryDateDiffQuery
DateDiffQuery
Matt R
 
DualScreenDualCPU
DualScreenDualCPUDualScreenDualCPU
DualScreenDualCPU
Matt R
 
LoyalKasparBackupPlanProposal
LoyalKasparBackupPlanProposalLoyalKasparBackupPlanProposal
LoyalKasparBackupPlanProposal
Matt R
 
MattSampleDatabase
MattSampleDatabaseMattSampleDatabase
MattSampleDatabase
Matt R
 
Sample Website
Sample WebsiteSample Website
Sample Website
Matt R
 
XenAppDoc
XenAppDocXenAppDoc
XenAppDoc
Matt R
 

More from Matt R (20)

EstimateExtraterrestrialLife
EstimateExtraterrestrialLifeEstimateExtraterrestrialLife
EstimateExtraterrestrialLife
 
LinuxPresentation500kb
LinuxPresentation500kbLinuxPresentation500kb
LinuxPresentation500kb
 
OpenBSD-pf-filter
OpenBSD-pf-filterOpenBSD-pf-filter
OpenBSD-pf-filter
 
PythonShutdownWindows
PythonShutdownWindowsPythonShutdownWindows
PythonShutdownWindows
 
TelephoneInfo-OpenInteraction
TelephoneInfo-OpenInteractionTelephoneInfo-OpenInteraction
TelephoneInfo-OpenInteraction
 
PhoneCallTools
PhoneCallToolsPhoneCallTools
PhoneCallTools
 
LaptopTrustIssues
LaptopTrustIssuesLaptopTrustIssues
LaptopTrustIssues
 
Interactions
InteractionsInteractions
Interactions
 
Interaction-Incident
Interaction-IncidentInteraction-Incident
Interaction-Incident
 
FoundationProcess
FoundationProcessFoundationProcess
FoundationProcess
 
FindStaffPerson
FindStaffPersonFindStaffPerson
FindStaffPerson
 
ChangesChecklist
ChangesChecklistChangesChecklist
ChangesChecklist
 
3tabs
3tabs3tabs
3tabs
 
bigalsnetwork
bigalsnetworkbigalsnetwork
bigalsnetwork
 
DateDiffQuery
DateDiffQueryDateDiffQuery
DateDiffQuery
 
DualScreenDualCPU
DualScreenDualCPUDualScreenDualCPU
DualScreenDualCPU
 
LoyalKasparBackupPlanProposal
LoyalKasparBackupPlanProposalLoyalKasparBackupPlanProposal
LoyalKasparBackupPlanProposal
 
MattSampleDatabase
MattSampleDatabaseMattSampleDatabase
MattSampleDatabase
 
Sample Website
Sample WebsiteSample Website
Sample Website
 
XenAppDoc
XenAppDocXenAppDoc
XenAppDoc
 

PythonPythagoreanTheorem

  • 1. # This program will take 2 numbers from the user and # find the hypotenuse using the Pythagorean theorem import math # Function to square the numbers def squarefunction(length): square = length * length print "The square of a side is: ", square return square # end of function # Function to calculate Pythagorean theorem def pythagorean(aside, bside): HypotenuseSquared = aside + bside hypotenuse = math.sqrt(HypotenuseSquared) print "The hypotenuse of the 2 sides is: ", hypotenuse # end of function # Get the length of the sides from the user firstside = input("Enter the first side: ") secondside = input("Enter the second side: ") # Get the squares of 2 sides firstsidesquared = squarefunction(firstside) secondsidesquared = squarefunction(secondside) # print "The firstside variable is: ", firstside # print "The secondside variable is: ", secondside # Put the squares into the Pythagorean function pythagorean(firstsidesquared, secondsidesquared)