Saturday, October 1, 2011

Test 0004: solving for a hypotenuse

#October 1, 2011
#Python 3.2 code by Carla Fuqua
#purpose: to allow a user to solve for a hypotenuse

#ask for values and assign to integers floats
w=float(input("Enter the width: "))
h=float(input("Enter the height: "))

#Pythagorean Theorem
hyp=(w*w+h*h)**(0.5)

#show hypotenuse
print('The hypotenuse is:',hyp)

#sweet!

Test 0003: receiving and processing user input

#October 1, 2011
#Python 3.2 code by Carla Fuqua
#purpose: to receive input and process it

#getting the input from the user
firstName=input('Enter your first name: ') #must add a space manually
lastName=input('Enter your last name: ')

#returning as output
print('''\nHello,''',firstName,lastName+"!") #commas turn into spaces, +'s do not
print(firstName+""", you have successfully completed this test.\
\nThank you for your participation.""")