Skip to content

Class and function

Sharkclass

class methods:

class functions & static methods:

Shark.swimclass(a)

Teach them how to swim

Parameters

self: obj – Instance of Shark.

Returns

bool – Did they succeed.

Source Code
1
2
3
4
5
6
7
8
@classmethod
def swimclass(self, a):

    print('prout')
    print("The shark is swimming.")
    for i in range(2):
        print("lololo")
    return

Shark.be_awesome(self)

Take the max between two numbers

Parameters

x: float – Description of parameter x.

y: float – Description of parameter y.

Returns

float – Description of returned object.

Source Code
1
2
3
def be_awesome(self):

    print("The shark is being awesome.")

Shark.swimstatic(self, a)

Teach them how to swim

Parameters

self: obj – Instance of Shark.

Returns

bool – Did they succeed.

Source Code
1
2
3
4
5
6
7
8
@staticmethod
def swimstatic(self, a):

    print('prout')
    print("The shark is swimming.")
    for i in range(2):
        print("lololo")
    return

maxi(x: int, y: int = 5)

Take the max between two numbers

Parameters

x: float – Description of parameter x.

y: float – Description of parameter y.

Returns

float – Description of returned object.

Source Code
1
2
3
def maxi(x: int, y: int = 5):

    return np.max(x, y)

maxi2pourvoir(x, y)

Take the max between two numbers

Parameters

x: float – Description of parameter x.

y: float – Description of parameter y.

Returns

float – Description of returned object.

Source Code
1
2
3
def maxi2pourvoir(x, y):

    return np.max(x, y)