python3 类间方法的调用

import numpy as np
class Calculate(object):
    def add(self, a, b):
        a1 = np.add(a,  b)
        return a1
    def multiply(self,a, b):
        a2= np.multiply(a, b)
        return a2
    def reduce(self,a,b):
        a3 = np.subtract(a, b)
        return a3
    def division(self,a, b):
        a4 = np.divide(a, b)
        return a4
class Total_grade(object):
    def __init__(self):
        self.Calculate = Calculate()
    def get_id(self,id):
        return id

    def get_name(self, grade):
        return grade

    def get_totalgrade(self, c, d):
        return self.Calculate.add(c, d)


s = Total_grade()
print(s.get_id('20130504310094'))
print(s.get_name('huazai'))
print(s.get_totalgrade(20, 30))
20130504310094
huazai
50

你可能感兴趣的:(python3 类间方法的调用)