def function in python
can anyone help me with def function in python ??
i have searched on web but couldn't understand properly so please help...
Okay here @ROCKINGRAYQUAZA
def say_hello(name): print("Hello " + name) say_hello("CoolJames") #"CoolJames" is the parameter that you want to pass into say_hello and the say_hello function will exceute (Hello CoolJames) say_hello(input("What is your name? ")) #What ever the user inputs will act as the parameter, so if I typed in James, the program will output "Hello James" # Note that functions have the be defined before you can use them. e.g. ''' say_hello("Bob") def say_hello(name): WRONG def say_hello(name) say_hello("Bob") RIGHT '''
Hope this helped. If you want any more help please say :)
If this answer helped please mark it :D