SlideShare a Scribd company logo
# 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
 
Import java
Import javaImport java
Import java
heni2121
 
Final project report
Final project reportFinal project report
Final project reportssuryawanshi
 
Functions
FunctionsFunctions
Functions
Swarup Boro
 
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
vikram mahendra
 
Programs.doc
Programs.docPrograms.doc
Programs.doc
ArnabNath30
 
AI-Programs.pdf
AI-Programs.pdfAI-Programs.pdf
AI-Programs.pdf
ArnabNath30
 
AI Lab menu for ptu students and easy to use and best quality and help for 6t...
AI Lab menu for ptu students and easy to use and best quality and help for 6t...AI Lab menu for ptu students and easy to use and best quality and help for 6t...
AI Lab menu for ptu students and easy to use and best quality and help for 6t...
Sonu880062
 
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
ARVIND PANDE
 
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 2Mohamed Ahmed
 
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
Kenneth Ceyer
 
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
HIMANSHU .
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
Thesis Scientist Private Limited
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
srxerox
 
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
 
OOP.pptx
OOP.pptxOOP.pptx
OOP.pptx
SanketAde1
 
C++ Function
C++ FunctionC++ Function
C++ FunctionHajar
 
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
lez31palka
 

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
 
AI Lab menu for ptu students and easy to use and best quality and help for 6t...
AI Lab menu for ptu students and easy to use and best quality and help for 6t...AI Lab menu for ptu students and easy to use and best quality and help for 6t...
AI Lab menu for ptu students and easy to use and best quality and help for 6t...
 
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
 

More from Matt R

EstimateExtraterrestrialLife
EstimateExtraterrestrialLifeEstimateExtraterrestrialLife
EstimateExtraterrestrialLifeMatt R
 
LinuxPresentation500kb
LinuxPresentation500kbLinuxPresentation500kb
LinuxPresentation500kbMatt R
 
OpenBSD-pf-filter
OpenBSD-pf-filterOpenBSD-pf-filter
OpenBSD-pf-filterMatt R
 
PythonShutdownWindows
PythonShutdownWindowsPythonShutdownWindows
PythonShutdownWindowsMatt R
 
TelephoneInfo-OpenInteraction
TelephoneInfo-OpenInteractionTelephoneInfo-OpenInteraction
TelephoneInfo-OpenInteractionMatt R
 
PhoneCallTools
PhoneCallToolsPhoneCallTools
PhoneCallToolsMatt R
 
LaptopTrustIssues
LaptopTrustIssuesLaptopTrustIssues
LaptopTrustIssuesMatt R
 
Interactions
InteractionsInteractions
InteractionsMatt R
 
Interaction-Incident
Interaction-IncidentInteraction-Incident
Interaction-IncidentMatt R
 
FoundationProcess
FoundationProcessFoundationProcess
FoundationProcessMatt R
 
FindStaffPerson
FindStaffPersonFindStaffPerson
FindStaffPersonMatt R
 
ChangesChecklist
ChangesChecklistChangesChecklist
ChangesChecklistMatt R
 
bigalsnetwork
bigalsnetworkbigalsnetwork
bigalsnetworkMatt R
 
DateDiffQuery
DateDiffQueryDateDiffQuery
DateDiffQueryMatt R
 
DualScreenDualCPU
DualScreenDualCPUDualScreenDualCPU
DualScreenDualCPUMatt R
 
LoyalKasparBackupPlanProposal
LoyalKasparBackupPlanProposalLoyalKasparBackupPlanProposal
LoyalKasparBackupPlanProposalMatt R
 
MattSampleDatabase
MattSampleDatabaseMattSampleDatabase
MattSampleDatabaseMatt R
 
Sample Website
Sample WebsiteSample Website
Sample WebsiteMatt R
 
XenAppDoc
XenAppDocXenAppDoc
XenAppDocMatt 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)