Sep-06-2019, 05:44 PM
I'm learning classes in Python and I've written a program that outputs the value of two integer variables. And I want to include a method that sums them. Everything works (the program successfully outputs the value of x and the value of y okay. But in the final print statement where I'm saying where I want to output the text and then call the function (in the print statement) to add the two together is where it's going wrong.
I'm not getting any specific error messages other than a "not listening" message.
Here is my program:
I'm not getting any specific error messages other than a "not listening" message.
Here is my program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
class SumTheIntegers: def __init__( self ): self .x = 10 self .y = 13 def sum_integers(): sum = x + y return sum def main(): SumIntegers = SumTheIntegers() print ( "The value of x is" , SumIntegers.x) print ( "The value of y is" , SumIntegers.y) print () print ( "The sum is" , SumIntegers.sum_integers()) main() |