+ 2
At fourth line what is diference between output=speak("shout") and output=speak(shout) ???
def shout(word): return word+"!" speak=shout output=speak("shout") print(output)
4 ответов
+ 4
'shout' would be a string so that would work fine and output "shout!".
Using shout without quotations on the other hand would give an error as you have not made a variable with that name and is therefore non-existent.
+ 1
thanks LP4 but after some study I thought that the problem is because of difference between types.
shout without Quotation is function and It can't be add with "!" that is a string.
+ 1
shout
+ 1
speak, shout and output are all functions. Although functions are created differently than normal variables, they are the same as any other type of value. They can be assigned or reassigned to variables and then referenced by these names
and then "shout" is the arguments , the input "shout" obey the pattern word +"!"
since shout = speak = output, you can change the code with:
def output(word):
return word + "!"
print(output("shout")
shout!