Python Forum
TypeError: type str doesn't define __round__ method
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: type str doesn't define __round__ method
#8
With f-string and in Python is better to us snake_case PEP-8.
wattage = float(input("What is the wattage of your device?"))
hours_used = float(input("What is the amount of hours used?"))
price_per_kWh = 11.76
electricity_cost = (wattage*hours_used) / (1000*price_per_kWh)
print(f"The cost of electricity is: {electricity_cost:.2f}")
Reply


Messages In This Thread
RE: TypeError: type str doesn't define __round__ method - by snippsat - Feb-03-2020, 08:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Changing client.get() method type based on size of data... dl0dth 1 688 Jan-02-2025, 08:30 PM
Last Post: dl0dth
Question TypeError: argument of type 'NoneType' is not iterable Tajaldeen 7 2,267 Nov-29-2024, 09:45 AM
Last Post: Tajaldeen
  i want to use type= as a function/method keyword argument Skaperen 9 3,587 Nov-06-2022, 04:28 AM
Last Post: Skaperen
  TypeError: unsupported operand type(s) for +: 'dict' and 'int' nick12341234 1 11,291 Jul-15-2022, 04:04 AM
Last Post: ndc85430
  TypeError: unsupported opperand type(s) for %: 'int' and 'list' cool_person 7 3,560 May-07-2022, 08:40 AM
Last Post: ibreeden
  Class Method to Calculate Age Doesn't Work gdbengo 1 2,502 Oct-30-2021, 11:20 PM
Last Post: Yoriz
  You have any idea, how fix TypeError: unhashable type: 'list' lsepolis123 2 3,882 Jun-02-2021, 07:55 AM
Last Post: supuflounder
  TypeError: __str__ returned non-string (type tuple) Anldra12 1 8,695 Apr-13-2021, 07:50 AM
Last Post: Anldra12
  TypeError: 'type' object is not subscriptable Stef 1 6,549 Aug-28-2020, 03:01 PM
Last Post: Gribouillis
  TypeError: unhashable type: 'set' Stager 1 3,403 Jun-08-2020, 04:11 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020