#mastery12 Creating python functions

I used this link to help me do this mastery: https://docs.python.org/2/tutorial/controlflow.html#defining-functions

It is also useful to read chapter 3 of the book “Think Python, How to Think Like a Computer Scientist”, 

You can see an example of this in my . Here’s the code showing the function that i created

def osuma (num1,num2): you have to define your function, in this case it’s osuma with num1 and num 2 as parameters

suma=num1+num2 is what the function does… this line must be idented so the function can work properly

return suma  #the return statement returns with a value from a function… this line must be idented so the function can work properly

 

num1 = int(input(“Give me a number: “)) 

num2 = int(input (“Give me another number: “))

su=osuma(num1,num2) i called osuma function i defined in order for the variable to take the function’s value

 

print (“The sum of your numbers is”, su) 

 

CC BY 4.0 #mastery12 Creating python functions by Gilberto Rogel García is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.