Skip to content

Instantly share code, notes, and snippets.

@tschoppi
Last active March 22, 2019 02:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tschoppi/f2f2e372f080478d3da4 to your computer and use it in GitHub Desktop.
Save tschoppi/f2f2e372f080478d3da4 to your computer and use it in GitHub Desktop.
Calculate the length of a 16-gauge wire according to the weight in pounds.
"""Calculate the length of a 16-gauge wire according to the weight in pounds."""
# Natural constants
PI = 3.14159
# Conversion factors
cmpin = 2.54 # cm / in
gplb = 453.6 # g / lb
# Constants
diam = 0.05082 * cmpin # cm
dens = 8.92 # g / cm^3
def wirelength(poundage):
"""Return length of wire in meters"""
mass = poundage * gplb # g
volume = mass / dens # cm^3
length = volume / (PI * diam**2) # cm
return length * 0.01 # m
print("Wire length of 1.00 lb of 16-gauge wire: {} m".format(round(wirelength(1.00), 2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment