Python 2 examples taken while learning SPSE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
529 B

# -*- coding: utf-8 -*-
class Calculator:
def __init__(self, ina, inb):
self.a = ina
self.b = inb
def add(self):
return self.a + self.b
def mul(self):
return self.a*self.b
newCalculation = Calculator(22,44)
print 'a+b: %d'%newCalculation.add()
print 'a*b: %d'%newCalculation.mul()
class Scientific(Calculator) :
def power(self):
return pow(self.a, self.b)
newPower = Scientific(6,7)
print 'a+b: %d'%newPower.add()
print 'a*b: %d'%newPower.mul()