# Kevin Michael Brownfield

## A Comprehensive Guide on Balloon Filling and Cost Estimation with Python

Balloons are often used for decoration and celebration, but have you ever wondered how many balloons it would take to lift a certain amount of weight? This Python program is designed to help you answer that question, as well as determine the cost of using balloons to lift a given weight. Additionally, the program allows you to compare the cost of filling the balloons yourself versus having them filled at a Party City store.

#### Explanation of the Code

Let’s go through the code line by line and see what each line does.

``````weight=int(input("How many pounds do you need to lift? \n"))
weight=float(weight)
``````

These lines prompt the user to input the weight they want to lift in pounds. The input value is initially read as a string, so the first line converts it to an integer. The second line then converts it to a float to ensure that any subsequent calculations produce accurate results.

``````num_balloons=round(weight*453.592/12)
``````

This line calculates the number of balloons needed to lift the specified weight. It does this by converting the weight from pounds to grams (using a factor of 453.592), dividing the result by the lift capacity of an individual balloon (12 grams), and rounding the answer to the nearest whole number.

``````balloon_cost1=round(float(.99*num_balloons))
balloon_cost2=round(float(1.29*num_balloons))
``````

These lines calculate the cost of the balloons needed to lift the specified weight. It does this by multiplying the number of balloons by the cost per balloon at Party City, which are set to be \$0.99 and \$1.29 for two different quality types, and then rounding the result to the nearest whole number.

``````helium_cost=round(float(1.40*num_balloons))
``````

This line calculates the cost of filling the balloons with helium at Party City. It does this by multiplying the number of balloons by the cost per cubic foot of helium, which is set to be \$1.40, and then rounding the result to the nearest whole number.

``````total1=balloon_cost1+helium_cost
total2=balloon_cost2+helium_cost
``````

These lines calculate the total cost of using balloons to lift the specified weight. They do this by adding the cost of the balloons and the cost of the helium together, with two different sets of balloons that have different costs.

``````print(f"You will need {num_balloons} balloons to lift {weight} pounds.\n")
print(f"That would cost you between \${balloon_cost1} and \${balloon_cost2} in balloons alone from Party City. \n")
print(f"It would cost \${helium_cost} to fill those balloons at Party City. \n")
print(f"The total cost to lift {weight} would be \${total1} to \${total2}. \n")``````

These lines print out the results of the calculations in a user-friendly format. It informs the user of the number of balloons needed to lift the weight, the cost of the balloons, the cost of filling the balloons with helium, and the total cost of using balloons to lift the weight.

``````while True:
fill_up_yourself = input("Do you want to fill up the balloons yourself? (y/n) \n").lower()
if fill_up_yourself == "y":
tank_size = input("What size tank are you planning to use in cubic feet of helium? 291/244/160/110/81/55/40/21 \n")
if tank_size == "291":
cost = (num_balloons / 582) * (410 + 408)
print(f"This would cost you \${cost:.2f}.\n")
break
elif tank_size == "244":
cost = (num_balloons / 488) * (396 + 338)
print(f"This would cost you \${cost:.2f}.\n")
break
elif tank_size == "160":
cost = (num_balloons / 320) * (360 + 247)
print(f"This would cost you \${cost:.2f}.\n")
break
elif tank_size == "110":
cost = (num_balloons / 220) * (319 + 189)
print(f"This would cost you \${cost:.2f}.\n")
break
elif tank_size == "81":
cost = (num_balloons / 162) * (269 + 148)
print(f"This would cost you \${cost:.2f}.\n")
break
elif tank_size == "55":
cost = (num_balloons / 110) * (219 + 110)
print(f"This would cost you \${cost:.2f}.\n")
break
elif tank_size == "40":
cost = (num_balloons / 80) * (189 + 98)
print(f"This would cost you \${cost:.2f}.\n")
break
elif tank_size == "21":
cost = (num_balloons / 42) * (129 + 61)
print(f"This would cost you \${cost:.2f}.\n")
break
else:
print("Please choose a valid tank size. \n")
else:
break

if cost < total1:
print("Filling the balloons yourself is the cheaper option.\n")
elif cost < total2:
print("Filling the balloons yourself is the cheaper option, but only slightly. \n")
else:
print("Having the balloons filled for you is the cheaper option. \n")

print('Balloon sizes may vary, calculations are based on the standard 11" latex balloon. These calculations are best described as estimates and do not include unexpected costs and accessories. \n')
``````

The next part of the code asks the user if they want to fill up the balloons themselves. If the user decides to fill up the balloons themselves, the code calculates the cost of filling up the balloons based on the tank size entered by the user. The cost of filling up the balloons depends on the tank size and the number of balloons required. The formula used for cost calculation varies with different tank sizes, and the code has pre-defined formulas for each tank size. The user is prompted to enter the tank size they plan to use, and based on the tank size entered, the code calculates the cost of filling up the balloons with helium.

After calculating the cost, the code then compares the cost of filling up the balloons with helium by the user to the cost of getting them filled at Party City. If the cost of filling up the balloons by the user is less than the cost of getting them filled at Party City, the code suggests that filling up the balloons themselves is the cheaper option. If the cost of filling up the balloons by the user is only slightly less than the cost of getting them filled at Party City, the code suggests that filling up the balloons themselves is the cheaper option, but only slightly. If the cost of filling up the balloons by the user is more than the cost of getting them filled at Party City, the code suggests that getting them filled at Party City is the cheaper option.

In conclusion, the code calculates the number of balloons needed to lift a specified weight, the cost of purchasing those balloons, the cost of filling up those balloons with helium, and the total cost of lifting that weight. The code also offers the user an option to fill up the balloons themselves and calculates the cost of doing so based on the tank size entered by the user. Finally, the code suggests whether filling up the balloons themselves or getting them filled at Party City is the cheaper option. The code is a useful tool for anyone who wants to calculate the cost of lifting a specific weight using balloons and helium.

This code might be useful for someone who is planning a party or an event where they want to create a fun and unique atmosphere. For example, they might want to create a festive balloon display or a balloon arch for a wedding or a birthday party. By using this code, they can calculate the number of balloons they need to lift a certain weight, and estimate the cost of purchasing balloons and filling them with helium.

Additionally, this code could be useful for someone who wants to save money on their event planning. By using the code to compare the cost of filling up the balloons themselves versus having them filled at a store like Party City, they can make an informed decision and potentially save money on their event.

Overall, this code could be a helpful tool for anyone who wants to plan a fun and memorable event with balloons.

Advertisement