Structure your code with indentation
Hey if we defining a function then why we wrote five instead function and why we are giving 1,2,3... Numbers when argumenting
Thanks for reaching out!
In the function definition, the function
five is defined to take a parameter
Inside the function, regardless of the passed argument,
x is immediately assigned a value of
The function then returns this value.
When you call the function using
five(3), the argument
3 is passed to the function. However, the function doesn't use this value because
x is immediately overwritten with the value 5.
Thus, the function will always return
5, irrespective of the argument provided.
In the provided example, we do this to demonstrate the difference between parameters and arguments in Python functions. By using different values, we can clearly illustrate how Python functions prioritize those, and in doing so, we get a clearer understanding of how parameters and arguments work in Python.
Hope this helps.