Math calculation

this is the code that im using to solve this but i keep getting an error

. be very grateful if someone can help me the program code is on the bottom.

#power_rating = int(input("what is the power rating of your device?: "))
#hours = int(input("how many hours used per day?: "))

#Perform monthly energy cost calculation 
def calculate_cost(power_rating,hours):
    consumption =(power_rating * hours) / 1000 #Formula to calculate monthly electricity consumption
    cost = consumption * 0.2156 #Formula to calculate monthly energy cost
    print("cost", cost) #Modify to display the calculated energy cost value

    return cost #Do not remove this line

#Do not remove the next line
calculate_cost(power_rating,hours)

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

1 Like