1.- First remember to define your functions before entering the inputs and other stuff:
print("On to functions")
def sumof (x,y):
return (x+y)
def substract (x,y):
return (x-y)
def multiply (x,y):
return (x*y)
def divide (x,y):
return (x/y)
def modulus (x,y):
return (x%y)
2.- Now that you have defined the functions you can ask for the values to the user:
x=int(input("Please write a number"))
y=int(input("Please write another number"))
3.- Apply the functions:
a=sumof(x,y)
b=substract(x,y)
c=multiply(x,y)
d=divide(x,y)
e=modulus(x,y)
4.- Print all the answers:
print ("the sum of both numbers is", a)
print ("the difference between both numbers is", b)
print ("the product between both numbers is", c)
print ("the division of both number is", d)
print ("the modulus operator of both numbers is", e)
If you need some help understanding functions go to: https://www.tutorialspoint.com/python3/python_functions.htm
I found some pretty useful stuff there.
#WSQ05
No hay comentarios:
Publicar un comentario