1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Basic Python Calc. - Problems with Bound Methods?

Discussão em 'Python' iniciado por Stack, Janeiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to make a basic addition class, but I am unable to get python to add the two variables together. When I run the code I get <unbound method Calc.add>. How would I resolve this?

    num1 = (input("Enter 1st Number: "))
    num2 = (input("Enter 2nd Number: "))

    class Calc(object):
    def __init__(self, num1, num2):
    self.num1 = num1
    self.num2 = num2
    def add(self):
    return num1 + num2
    CC = Calc(num1,num2)

    print CC.add

    Continue reading...

Compartilhe esta Página