For this task we were meant to create a programm that performs the same as the WSQ03. This means the programm would have to calculate the addition, substraction, multiplication, division and reminder of two INTEGERS given by the user, but this tame we had to declare one function for each calculation.

To define a function you must type the special word “def” and then write the name of the function and after tht you can decide to put o or no to put parameters inside parenthesis, like this:

def sum(a,b)

The code i wrote is this:

#Jorge Fernando Saldaña Cabal
# A01350730

def add(x,y):
z = x+y
return z
def sus(x,y):
z = x-y
return z
def mul(x,y):
z = x*y
return z
def div(x,y):
z = x//y
return z
def rem(x,y):
z = x%y
return z
print ()

print (‘Hey!, Do you want to make some math’)
print(‘Lets make the basic operations: Addition, Sustraction, Multiplication and’)
print(‘Division’)
print()
x = int(input(‘Please enter your firste integer: ‘))
print()
y = int(input(‘Please enter your second integer: ‘))
print(‘The addition of your two numbers is: ‘, add(x,y), ‘, the sustracion is: ‘, sus(x,y))
print(‘the multiplication is: ‘, mul(x,y), ‘, the division is: ‘, div(x,y))
print(‘and its reminder is: ‘, rem(x,y))
print (‘Thanks for using us.’)

Which will be seen as this with the values 3 and 6:

Captura de pantalla de 2015-10-22 16:08:45

CC BY 4.0 On to functions by fersabal is licensed under a Creative Commons Attribution 4.0 International License.