# kargupy / euc-cli / euc-cli_0.3.py

 ``` 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94``` ```#============================ # Energy Usage Calculator # Program Code # Version: 0.3 | Functional #============================ # Initial SI = "========================================" SII = "----------------------------------------" # Input print SI print "Energy Usage Calculator" print SII # Count def askdata(): global name, VA, NEA, dataWHn name = raw_input("What's your name? ") VA = input("How much your VA? ") NEA = input("Number of electronic appliances : ") dataWHn = [] for n in range(1,NEA+1): def ask(): global W,H askW = "EA %d\t| Power (Watt) = " % n askH = "\t| Usage (Hour) = " W = input(askW) H = input(askH) ask() if H > 24: print "Usage must be <24 hours!" ask() else: dataWHn.append([W,H]) def countWH(dataWHn): global dataWH dataWH = [] for W,H in dataWHn: WH = W * H dataWH.append(WH) def countDWH(dataWH): global DWH DWH = 0 for WH in dataWH: DWH += WH def countMWH(DWH): global MWH MWH = 0 MWH = DWH * 30 def countMKWH(MWH): global MKWH MKWH = 0 MKWH = MWH / float(1000) def countMPKWH(): global MPKWH, TAX if VA >= 6600: MPKWH = 1380 elif VA < 6600: MPKWH = 600 else: MPKWH = 0 if VA >= 450 and VA <= 1300: TAX = 0.03 elif VA > 1300 and VA <= 5500: TAX = 0.05 elif VA > 5500: TAX = 0.06 else: TAX = 0.06 def countMB(MKWH): global MB MB = 0 MB = MKWH * MPKWH MB = MB + (MB*TAX) # Process askdata() countWH(dataWHn) countDWH(dataWH) countMWH(DWH) countMKWH(MWH) countMPKWH() countMB(MKWH) # Output print SII print "Your name\t\t= %s" % name print "Household power\t\t= %s VA" % VA for n in range(1,NEA+1): print "Electronic Appliance %d\t= %d Wh" % (n,dataWH[n-1]) print "Daily Watt Hour\t= %d Wh" % DWH print "Monthly Watt Hour\t= %d Wh" % MWH print "Monthly kWh\t\t= %s kWh" % str(MKWH) print "Monthly Price/kWh\t= Rp %d" % MPKWH print "Monthly Tax\t\t= %d %% = Rp %d" % ((TAX*100),(MB*TAX)) print "Monthly Bills\t\t= Rp %d" % MB print SI ```