Skip to content
Snippets Groups Projects
Commit 44222ed4 authored by Laros's avatar Laros
Browse files

Added calculator assignment.

parent dd1be418
Branches
No related tags found
No related merge requests found
#!/usr/bin/env python
class Stack(list):
def push(self, element):
self.append(element)
def __str__(self):
return str(self[-1])
class Calculator(Stack):
def add(self):
self.push(self.pop() + self.pop())
def sub(self):
temp = self.pop()
self.push(self.pop() - temp)
def mul(self):
self.push(self.pop() * self.pop())
def div(self):
temp = self.pop()
self.push(self.pop() / temp)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment