Advertisement
ray_jpl

Untitled

Mar 22nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1.  
  2. #Establising values [length,height,depth] (cm)
  3. budget = [50,35,30]
  4. superior = [40,30,35]
  5. lux = [30,25,40]
  6. pi=3.14159
  7. import math
  8.  
  9. def working(budget,superior,lux,pi):
  10. loop = True
  11.  
  12. #Inputs (Converted to cm)
  13. while loop == True:
  14. validH = False
  15. validF = False
  16. validT = False
  17. validLS = False
  18. while validH == False:
  19. print("-------------------------------")
  20. high = (float(input("Enter desired height in metres: ")))*100
  21. if high>=100 and high<=100000:
  22. validH = True
  23. else:
  24. print("Enter a Valid height below or equal to 1000m")
  25.  
  26. while validF == False:
  27. dF = (float(input("Enter desired foundation Diameter in metres: ")))*100
  28. if dF>=100 and dF<=100000:
  29. validF = True
  30. else:
  31. print("Enter a valid foundation diameter less than or equal to 1000m")
  32.  
  33. while validT == False:
  34. dT = (float(input("Enter desired Diameter of the top in metres: ")))*100
  35. if dT>=100 and dT<=100000:
  36. validT = True
  37. else:
  38. print("Enter a valid top diameter less than or equal to1000m")
  39.  
  40. while validLS == False:
  41. LStyle = int(input("Enter desired building style with the appropriate number: \n1. Budget \n2. Superior \n3. Luxury \nBuild Style Number: "))
  42. if LStyle == 1 or LStyle == 2 or LStyle == 3:
  43. validLS = True
  44. else:
  45. print("Type 1,2 or 3 to select a lighthouse type")
  46. loop = False
  47.  
  48.  
  49.  
  50.  
  51. #Determining the high of the lighthouse in terms of blocks. Always rounding up to the nearest block
  52. def blockH(high,LStyle):
  53. if LStyle == 1:
  54. bHigh = high/budget[1]
  55. if LStyle == 2:
  56. bHigh = high/superior[1]
  57. if LStyle == 3:
  58. bHigh = high/lux[1]
  59. return(math.ceil(bHigh))
  60.  
  61.  
  62. #Determines sum of all circumferences
  63. def circsum(dF,dT,blockH,high,LStyle,pi):
  64. #Determining the diameter for the interior of the tower
  65. if LStyle == 1:
  66. innerdF = dF - 2*budget[2]
  67. innerdT = dT - 2*budget[2]
  68. if LStyle == 2:
  69. innerdF = dF - 2*superior[2]
  70. innerdT = dT - 2*superior[2]
  71. if LStyle == 3:
  72. innerdF = dF - 2*lux[2]
  73. innerdT = dT - 2*lux[2]
  74. #Determining the difference of circumference between each layer
  75. circDiff = (pi*innerdF - pi*innerdT)/blockH(high,LStyle)
  76.  
  77. #Circumference of foundation
  78. circdF = pi*innerdF
  79.  
  80. #Finds each circumference from bottom to top.
  81. #Adds them together within a list and finds the total length of all circumferences
  82. circum = [circdF]
  83. x=0
  84. while x < blockH(high,LStyle):
  85. circdF = circdF - circDiff
  86. circum.append(circdF)
  87. x=x+1
  88. circumsum = sum(circum)
  89. return circumsum
  90.  
  91.  
  92.  
  93.  
  94. #Calculates the number of blocks needed(circumference)
  95. def circumB(LStyle,circsum):
  96. if LStyle == 1:
  97. circB = circsum(dF,dT,blockH,high,LStyle,pi)/budget[0]
  98. if LStyle == 2:
  99. circB = circsum(dF,dT,blockH,high,LStyle,pi)/superior[0]
  100. if LStyle == 3:
  101. circB = circsum(dF,dT,blockH,high,LStyle,pi)/lux[0]
  102. return circB
  103.  
  104.  
  105.  
  106.  
  107. #Determining the amount of Door Blocks. 200cm x 90cm.
  108. #Uses the measurement of length of block as the exterior of the lighthouse is in terms of lengths of blocks not width/depth of the blocks
  109. def doorB(LStyle):
  110. if LStyle == 1:
  111. doorW = 90/budget[0]
  112. doorL = 200/budget[1]
  113. doorBlocks = doorW*doorL
  114. if LStyle == 2:
  115. doorW = 90/superior[0]
  116. doorL = 200/superior[1]
  117. doorBlocks = doorW*doorL
  118. if LStyle == 3:
  119. doorW = 90/lux[0]
  120. doorL = 200/lux[1]
  121. doorBlocks = doorW*doorL
  122. return(doorBlocks)
  123.  
  124.  
  125.  
  126. #Total Amount of Blocks
  127. def Total(circumB,LStyle,circsum,doorB):
  128. TotalB = math.ceil(circumB(LStyle,circsum) - doorB(LStyle))
  129. return TotalB
  130.  
  131. return Total(circumB,LStyle,circsum,doorB)
  132.  
  133.  
  134. def Answer(working):
  135. print("\nThe total amount of blocks needed:",working(budget,superior,lux,pi))
  136. Start = input("\nStart a new Calculation? Y/N:")
  137. looper = True
  138. while looper == True:
  139. looper = False
  140. if Start == "N":
  141. loop = "N"
  142. print("Program ended")
  143.  
  144. elif Start == "Y":
  145. loop = True
  146. Answer(working)
  147. else:
  148. print("Enter Y or N")
  149. looper = True
  150.  
  151. Answer(working)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement