public
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
⚙⮀~/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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.