Hello all, first timer here.
I was wondering what the point of keywording something in the parameter is ? In the example of the exercise that have been mentioned in this thread:
def greet_customer(special_item, grocery_store=“Engrossing Grocer’s”):
print("Welcome to "+ grocery_store + “.”)
print("Our special is " + special_item + “.”)
print(“Have fun shopping!”)
Engrossing Grocer’s has now been keyworded into the parameter’s positional arguements.
It seems to me that this is extra work and redundant coding, since keywording something to a parameter is pretty much the same as me doing this :
def greet_customer(special_item):
print(“Welcome to Engrossing Grocer’s.”)
print("Our special is " + special_item + “.”)
print(“Have fun shopping!”)
now isn’t that pretty much the same as me keywording it into the parameter ? but with less code ?
or does keywording something as in the example have broader uses ?
also, on a side note. How do I store a functions output as a variable ?
ex:
def somernumbers(number, x, y)
print(number + x*y)
somenumbers(5, 3, 2)
now that prints the number to the console, but
how do I go about storing that number/function as a variable ? I’ve tried all sorts of things, but with no luck.
Thank you all so much in advance.