Syntax of answer in 5.14


#1
def greater_less_equal_5(**answer**):
    if **answer** > 5:
        return 1
    elif **answer** < 5:          
        return -1
    else:
        return 0

Hello, this is my first post, I am enjoying learning Python with Codeacademy. Everyone has been very friendly so far, in my opinion.

My question is about why the word answer does not have any quotations or parentheses around it. Is it a string? Or is answer used by itself? I may be jumping ahead of myself.


#2

1

Please re-edit your Post

  • select your code in the Post
  • then =click= on the </>-symbol-of-this-editor

Your code will then be in a pre-code state
and you will be able to make/present the proper indentations.

2

With

def greater_less_equal_5(answer):
    if answer > 5:
        return 1
    elif answer < 5: 
        return -1
    else:
        return 0

you have defined a greater_less_equal_5 function
which take's 1 parameter answer
( the parentheses-( ) are also called parameter-holders )
answer is used as a variable throughout the function.

Now as you call the greater_less_equal_5 function
greater_less_equal_5()
and the greater_less_equal_5 function was defined as having 1 parameter
you will have to provide 1 argument which in this case should be a number Value
like
greater_less_equal_5(10)
or
if we had a variable to which a number Value was assigned
number_to_check = 10
we could have called the greater_less_equal_5 function
like
greater_less_equal_5(number_to_check)

some quotes from the outer-world:

**argument is the value/variable/reference being passed in,
parameter is the receiving variable used within the function/block**

OR

**"parameters" are called "formal parameters",
while "arguments" are called "actual parameters".**


#3

Thank you for the explanation, this definitely helps explain some of the gaps for me.