Skip to content

Instantly share code, notes, and snippets.

@SweiLz
Created April 22, 2020 14:59
Show Gist options
  • Save SweiLz/288cceef32ca06eac936eae7dbfd3b69 to your computer and use it in GitHub Desktop.
Save SweiLz/288cceef32ca06eac936eae7dbfd3b69 to your computer and use it in GitHub Desktop.
ฟังก์ชั่นคำนวณค่าไฟออกมาเป็นหน่วยบาท
def calUnit(unit,Ft = -11.6):
total = 0
temp_unit = unit
if unit <= 150:
print("Case: ","1.1")
else:
print("Case: ","1.2")
if temp_unit > 400:
total += ((temp_unit-400) * 4.4217)
temp_unit = 400
# total += (250 * 4.2218)
# total += (150 * 3.2484)
if temp_unit > 150:
total += (temp_unit-150 * 4.2218)
total += (150 * 3.2484)
temp_unit = 150
elif temp_unit > 150:
pass
return total
if __name__ == "__main__":
# print(calUnit(1231,-11.6))
print(calUnit(400,-11.6))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment