Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PYTHON #100

Open
guptapooja1906 opened this issue Jun 2, 2017 · 1 comment
Open

PYTHON #100

guptapooja1906 opened this issue Jun 2, 2017 · 1 comment

Comments

@guptapooja1906
Copy link

hi bucky,
I did not understood the topic return values. could you please help me to explain with another example.

Reply soon

@yeyeto2788
Copy link

Sorry for just commenting here out of the blue.

Maybe I can also help here. I'll use same example so you can have a better idea.

def allowed_dating_age(my_age):
    girls_age = my_age/2 + 7
    return girls_age

buckys_limit = allowed_dating_age(27)
creepy_joe_limit = allowed_dating_age(49)
print("Bucky can date girls", buckys_limit, "or older")
print("Creepy Joe can date girls", creepy_joe_limit, "or older")

Take into account that when you setup a value when calling the function like in

buckys_limit = allowed_dating_age(27)

what you are actually doing is putting the values into the function

def allowed_dating_age(my_age):
    girls_age = my_age/2 + 7
    return girls_age

so let me change the value on my_age variable so you can have a better picture

def allowed_dating_age(27):
    girls_age = 27/2 + 7
    return girls_age

this 27 will be divided by 2 and then we'll add 7, the formula will be like this: (27/2) + 7 = 20,5. The result of the formula will be stored on girls_age variable so the return girls_age will give to buckys_limit variable that value (20,5).

If you want another example would be:

def sum(a,b):
    c = a + b
    return c

Here you are just doing a sum of two variable and return the value of that operation.

I hope it helps a bit.
Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants