Python Forum
Everything works except for one line of code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Everything works except for one line of code
#2
You need to look a little bit more into python oop

class SumTheIntegers:
    def __init__(self, x, y):
        self.x = x
        self.y = y
 
    def _sum(self):
        return self.x + self.y
     
def main():
    sum_integers = SumTheIntegers(10, 13)
     
    print("The value of x is", sum_integers.x)
    print("The value of y is", sum_integers.y)
    print()
    print("The sum is", sum_integers._sum())
     
main()
Reply


Messages In This Thread
RE: Everything works except for one line of code - by ThomasL - Sep-06-2019, 05:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to understand the meaning of the line of code. jahuja73 0 364 Jan-23-2024, 05:09 AM
Last Post: jahuja73
  My code works on Jupyter Lab/Notebook, but NOT on Visual Code Editor jst 4 1,205 Nov-15-2023, 06:56 PM
Last Post: jst
  Code works but doesn't give the right results colin_dent 2 774 Jun-22-2023, 06:04 PM
Last Post: jefsummers
  Code used to work 100%, now sometimes works! muzicman0 5 1,548 Jan-13-2023, 05:09 PM
Last Post: muzicman0
  Trying to loop through code to plot seaborn line plots across multiple subplots eyavuz21 0 1,761 Dec-05-2022, 10:46 AM
Last Post: eyavuz21
  Pandas - error when running Pycharm, but works on cmd line zxcv101 1 1,407 Jun-18-2022, 01:09 PM
Last Post: snippsat
  Python code to read second line from CSV files and create a master CSV file sh1704 1 2,463 Feb-13-2022, 07:13 PM
Last Post: menator01
  Pyspark - my code works but I want to make it better Kevin 1 1,850 Dec-01-2021, 05:04 AM
Last Post: Kevin
Question email code works in 2.7 but not in 3 micksulley 3 2,648 Nov-04-2021, 09:44 PM
Last Post: micksulley
  My simple code don't works !! Nabi666 1 1,642 Sep-06-2021, 12:10 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

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