Skip to content

Instantly share code, notes, and snippets.

@ranman
Created October 10, 2013 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ranman/6913539 to your computer and use it in GitHub Desktop.
Save ranman/6913539 to your computer and use it in GitHub Desktop.
⚙⮀~/test⮀ cat test.py
print("=========================================================")
print(
format("Name", '<12s'),
format("Type", '<15s'),
format("Location", '<10s'),
format("KwH", '>6s'),
format("Total", '>10s')
)
print("=========================================================")
total = 0
for i in range(10):
custName, custType, custLoc, custKwh = input().split(' ')
custKwh = int(custKwh)
if (custType == "R"):
custType = "Residential"
if (custType == "B"):
custType = "Business"
total = (custKwh * 0.05710) + 10
if (custLoc == "C"):
custLoc = "City"
total = (custKwh * 0.0401) + 6
if (custLoc == "P"):
custLoc = "Parish"
total = (custKwh * 0.04411) + 6.60
print(
format(custName, '<12s'),
format(custType, '<15s'),
format(custLoc, '<10s'),
format(custKwh, '>6d'),
format(total, '>10.2f')
)
⚙⮀~/test⮀ cat pa3.data
Smith R P 4500
Taylor R C 6000
Williams B C 10500
Johnson R C 7500
Davis R P 3000
Woods B P 25300
Morgan R C 5800
Landry R C 3900
Young B P 18500
Wilson R P 7000
⚙⮀~/test⮀ python3 test.py < pa3.data
=========================================================
Name Type Location KwH Total
=========================================================
Smith Residential Parish 4500 205.09
Taylor Residential City 6000 246.60
Williams Business City 10500 427.05
Johnson Residential City 7500 306.75
Davis Residential Parish 3000 138.93
Woods Business Parish 25300 1122.58
Morgan Residential City 5800 238.58
Landry Residential City 3900 162.39
Young Business Parish 18500 822.64
Wilson Residential Parish 7000 315.37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment