Skip to content

Commit

Permalink
Merge pull request #1 from PadamSethia/PadamSethia-patch-1
Browse files Browse the repository at this point in the history
Added sum_classes.py
  • Loading branch information
highoncarbs committed Oct 9, 2017
2 parents 935317a + 79059ee commit cdf18e7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions SimpleAddition/sum_classes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This example uses python classes for addition

class Numbers(object):
def __init__(self):
self.sum = 0

def add(self,x):
# Addtion funciton
self.sum += x

def total(self):
# Returns the total of the sum
return self.sum



if __name__ == "__main__":
# Prints 12 on the terminal when the file is run,
# you can even use input() to get numbers from
# users.

add = Numbers()
add.add(5)
add.add(7)
y = add.total()
print("Total Sum : " , y)

0 comments on commit cdf18e7

Please sign in to comment.