Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Establising values [length,height,depth] (cm)
- budget = [50,35,30]
- superior = [40,30,35]
- lux = [30,25,40]
- pi=3.14159
- import math
- def working(budget,superior,lux,pi):
- loop = True
- #Inputs (Converted to cm)
- while loop == True:
- validH = False
- validF = False
- validT = False
- validLS = False
- while validH == False:
- print("-------------------------------")
- high = (float(input("Enter desired height in metres: ")))*100
- if high>=100 and high<=100000:
- validH = True
- else:
- print("Enter a Valid height below or equal to 1000m")
- while validF == False:
- dF = (float(input("Enter desired foundation Diameter in metres: ")))*100
- if dF>=100 and dF<=100000:
- validF = True
- else:
- print("Enter a valid foundation diameter less than or equal to 1000m")
- while validT == False:
- dT = (float(input("Enter desired Diameter of the top in metres: ")))*100
- if dT>=100 and dT<=100000:
- validT = True
- else:
- print("Enter a valid top diameter less than or equal to1000m")
- while validLS == False:
- LStyle = int(input("Enter desired building style with the appropriate number: \n1. Budget \n2. Superior \n3. Luxury \nBuild Style Number: "))
- if LStyle == 1 or LStyle == 2 or LStyle == 3:
- validLS = True
- else:
- print("Type 1,2 or 3 to select a lighthouse type")
- loop = False
- #Determining the high of the lighthouse in terms of blocks. Always rounding up to the nearest block
- def blockH(high,LStyle):
- if LStyle == 1:
- bHigh = high/budget[1]
- if LStyle == 2:
- bHigh = high/superior[1]
- if LStyle == 3:
- bHigh = high/lux[1]
- return(math.ceil(bHigh))
- #Determines sum of all circumferences
- def circsum(dF,dT,blockH,high,LStyle,pi):
- #Determining the diameter for the interior of the tower
- if LStyle == 1:
- innerdF = dF - 2*budget[2]
- innerdT = dT - 2*budget[2]
- if LStyle == 2:
- innerdF = dF - 2*superior[2]
- innerdT = dT - 2*superior[2]
- if LStyle == 3:
- innerdF = dF - 2*lux[2]
- innerdT = dT - 2*lux[2]
- #Determining the difference of circumference between each layer
- circDiff = (pi*innerdF - pi*innerdT)/blockH(high,LStyle)
- #Circumference of foundation
- circdF = pi*innerdF
- #Finds each circumference from bottom to top.
- #Adds them together within a list and finds the total length of all circumferences
- circum = [circdF]
- x=0
- while x < blockH(high,LStyle):
- circdF = circdF - circDiff
- circum.append(circdF)
- x=x+1
- circumsum = sum(circum)
- return circumsum
- #Calculates the number of blocks needed(circumference)
- def circumB(LStyle,circsum):
- if LStyle == 1:
- circB = circsum(dF,dT,blockH,high,LStyle,pi)/budget[0]
- if LStyle == 2:
- circB = circsum(dF,dT,blockH,high,LStyle,pi)/superior[0]
- if LStyle == 3:
- circB = circsum(dF,dT,blockH,high,LStyle,pi)/lux[0]
- return circB
- #Determining the amount of Door Blocks. 200cm x 90cm.
- #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
- def doorB(LStyle):
- if LStyle == 1:
- doorW = 90/budget[0]
- doorL = 200/budget[1]
- doorBlocks = doorW*doorL
- if LStyle == 2:
- doorW = 90/superior[0]
- doorL = 200/superior[1]
- doorBlocks = doorW*doorL
- if LStyle == 3:
- doorW = 90/lux[0]
- doorL = 200/lux[1]
- doorBlocks = doorW*doorL
- return(doorBlocks)
- #Total Amount of Blocks
- def Total(circumB,LStyle,circsum,doorB):
- TotalB = math.ceil(circumB(LStyle,circsum) - doorB(LStyle))
- return TotalB
- return Total(circumB,LStyle,circsum,doorB)
- def Answer(working):
- print("\nThe total amount of blocks needed:",working(budget,superior,lux,pi))
- Start = input("\nStart a new Calculation? Y/N:")
- looper = True
- while looper == True:
- looper = False
- if Start == "N":
- loop = "N"
- print("Program ended")
- elif Start == "Y":
- loop = True
- Answer(working)
- else:
- print("Enter Y or N")
- looper = True
- Answer(working)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement