Last active
July 20, 2017 03:40
-
-
Save MattSegal/92edb226d275ffc5d325e095dd0e768c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function # Ignore this | |
# Example 1 - Function with argument | |
def say_hello(name): | |
# Prints 'Hello {name}!' to the screen | |
print("Hello {}!".format(name)) | |
# We 'invoke' / 'call' a function using the ()s | |
say_hello('Nick') | |
# If you want to assign the function to a variable, just don't do the ()s | |
a_variable = say_hello | |
# Then you can invoke it using ()s | |
a_variable('Matt') | |
# Example 2 - Function with no argument | |
def say_hello_to_stranger(): | |
# Prints 'Hello stranger!' to the screen | |
print("Hello stranger!") | |
say_hello_to_stranger() | |
some_variable = say_hello_to_stranger | |
some_variable() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment