Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def calculation(operation):
- if operation == "area1":
- input1 = input("Base > ")
- input2 = input("Heigh > ")
- number1 = float(input1)
- number2 = float(input2)
- result = (number1 * number2)/2
- output = str(result)
- print ("The result of 'area1' is " + str(result) + " m^2")
- else:
- input1 = input("Side 'a' > ")
- input2 = input("Side 'b' > ")
- input3 = input("Side 'c' > ")
- number1 = float(input1)
- number2 = float(input2)
- number3 = float(input3)
- result = (number1 + number2 + number3)/2
- output = str(result)
- print("The result of 'area2' is " + str(result) + " m^2")
- return
- # Area1: Calculates the area using the base and height
- # Area2: Calculates the area using triangulation (based on the length of the three sides)
- print("Let's do triangle's area")
- # loop
- finished = False
- while finished == False:
- operation = input("What calculation would you like to do 'area1'> (base*heigh/2) or 'area2'> (side a + side b + side c /2)?: ")
- if operation in ["area1","area2"]:
- calculation(operation)
- else:
- print("I'm sorry, I don't understand " + operation)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement