Typeerror: not all Arguments converted During string formatting - Python 3.6 - Power Bill

Asked

Viewed 54 times

2

I am a beginner in the area and during the programming studies in Python I was stuck in this exercise, the goal being to appear on the screen of the user how much he should pay per kwh used, depending on whether it is for commerce, industry or residence, having different rates depending on the specific limit.

    w = float(input("Qual o valor de kWh consumidos? "))
    i = input("Qual o tipo de instalação elétrica? Digite R para residências, I para indústrias ou C para comércios: ")
    if i == "R":
      if w<=500:
      print("O valor a ser pago pelo fornecimento de energia é de R$%5.2f." % (w*0,40))
      else:
    print("O valor a ser pago pelo fornecimento de energia é de R$%5.2f." % (w*0,65))
    elif i == "I":
      if w<=5000:
      print("O valor a ser pago pelo fornecimento de energia é de R$%5.2f." % (w*0,55))
      else:
      print("O valor a ser pago pelo fornecimento de energia é de R$%5.2f." % (w*0,60))
    elif i == "C":
      if w<=1000:
      print("O valor a ser pago pelo fornecimento de energia é de R$%5.2f." % (w*0,55))
      else:
      print("O valor a ser pago pelo fornecimento de energia é de R$%5.2f." % (w*0,60))
   else:
   print("Por gentileza, escolha uma das 3 opções digitando corretamente entre R, I e C.")

As a beginner, I will be very grateful for any hint if anything is wrong. Thank you from now!

  • Try changing the commas by a dot: .. Gia is R$%5.2f." % (w*0.40))

  • 1

    Wow... since I didn’t see it, what a shame. Thank you!!!

  • Since you’re starting now I suggest you start with Python 3 right away. The differences in Python 2 make learning much easier

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.