simplefunction.py 908 B

1234567891011121314151617181920212223
  1. #!/usr/bin/env python3
  2. """ A simple example of function declarations and main. """
  3. def example(firstargument, secondargument, thirdargument="N/A"):
  4. """ Prints a string based on the two arguments. """
  5. # This is python3.6 syntax:
  6. # print(f"{firstargument} is the first argument.")
  7. print("{a} is the first argument.".format(a=firstargument)) # Name the argument if you want
  8. print("{} is the second argument.".format(secondargument))
  9. print("{} is the third argument.".format(thirdargument))
  10. if __name__ == "__main__":
  11. """
  12. Some examples on simple functions.
  13. And docstring stuff that will probably have to be updated when I know more.
  14. """
  15. # You can just use parameters in order
  16. example("My first argument", "my second argument")
  17. # but better to use the names, without spaces here!
  18. example(secondargument="#2!", firstargument="#1!", thirdargument="#3!")