Advertisement
MrsMcLead

ECS Measurements

Nov 19th, 2013
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.22 KB | None | 0 0
  1. from tkinter import *
  2. import tkinter.simpledialog
  3. import tkinter.messagebox
  4.  
  5. root = Tk()
  6. w = Label(root, text="Measurements")
  7. w.pack()
  8.  
  9. #use me as an example of how to do the rest.
  10. #area = lw
  11. def rectanglearea(length, width):
  12.     area = length * width
  13.     return area
  14.  
  15. # 0 - make sure you look at the example above.
  16. #volume = lwh
  17. def prismvolume(length, width, height):
  18.    
  19.     return
  20.  
  21. # 1
  22. #perimeter = side1 + side2 + side3
  23. def triangleperimeter(side1, side2, side3):
  24.  
  25.     return
  26.    
  27. # 2 - it's one half base times height, so multiply and divide by two.
  28. #area = bh/2
  29. def trianglearea(base, height):
  30.  
  31.     return
  32.    
  33. # 3 - yes, you need to use the paretheses.
  34. #perimeter = 2(l + w)
  35. def rectangleperimeter(length, width):
  36.  
  37.     return
  38.    
  39.    
  40. #EXTRA CREDIT.  The Surface Area of a rectangular prism is the perimeter of the base
  41. #multiplied by the height(SA = ph).  Write a function to calulate the surface area
  42. #of a rectangular prism with sides 5, 7 and 2.  Write it as efficiently as
  43. #possible (don't rewrite code that you don't have to)
  44.      
  45.    
  46. areaR = rectanglearea(5, 7)
  47. tkinter.messagebox.showinfo("rectangle area", "Area of a rectangle with sides 5 and 7 is " + str(areaR))
  48.    
  49. volumeP = prismvolume(5, 7, 2)
  50. tkinter.messagebox.showinfo("prism volume", "Volume of a rectagular prism with sides 5, 7 and 2 is " + str(volumeP))
  51.    
  52. perimeterT = triangleperimeter(10, 7, 8)
  53. tkinter.messagebox.showinfo("triangle perimeter", "Perimeter of a triangle with sides 10, 7 and 8 is " + str(perimeterT))
  54.    
  55. areaT = trianglearea(6, 8)
  56. tkinter.messagebox.showinfo("triangle area", "Area of a triangle with base 6 and height 8 is " + str(areaT))   
  57.    
  58. perimeterR = rectangleperimeter(5, 8)
  59. tkinter.messagebox.showinfo("rectangle perimeter", "Perimeter of a rectangle with sides 5 and 8 is " + str(perimeterR))
  60.  
  61. #
  62. #  If your program works, you should get the following answers:
  63. #
  64. #   Area of a rectangle with sides 5 and 7 is 35
  65. #   Volume of a rectagular prism with sides 5, 7 and 2 is 70
  66. #   Perimeter of a triangle with sides 10, 7 and 8 is 25
  67. #   Area of a triangle with base 6 and height 8 is 24
  68. #   Perimeter of a rectangle with sides 5 and 8 is 26
  69. #
  70. #   Extra Credit:
  71. #   Surface Area of a rectangular prism with sides 5, 7 and 2 is 48
  72. #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement