Skip to content

Instantly share code, notes, and snippets.

@compscitwilight
Last active February 12, 2024 18:21
Show Gist options
  • Save compscitwilight/7e84b2b6f050e1526ef1d5ffdf031457 to your computer and use it in GitHub Desktop.
Save compscitwilight/7e84b2b6f050e1526ef1d5ffdf031457 to your computer and use it in GitHub Desktop.
Python script to calculate the total wattage of a power supply in a given amount of time, and also calculate for the price/KWh in a given time period.
psu_watts = int(input("Power supply wattage (w): "))
price_per_wh = float(input("Price per kilowatt hour (cents): "))
days = int(input("Days: "))
total_wattage = psu_watts * (days * 24)
total_price = ((total_wattage / 1000) * price_per_wh) / 100
print()
print("Total wattage: " + str(total_wattage))
print("Total price for " + str(price_per_wh) + "c/KWh: $" + str(total_price))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment