Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ultimatepython/syntax/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ def sum_until(fn, n):
return total


def without_parameters():
"""A function that does not accept parameters and does not return a value."""
pass


def sum(x: int, y: int) -> int:
"""A function that accepts parameters and has type hints."""
return x + y


def main():
# The `add` function can be used for numbers as expected
add_result_int = add(1, 2)
Expand All @@ -54,6 +64,10 @@ def main():
# attribute! Remember this - everything in Python is an object
assert "includes this docstring!" in sum_until.__doc__

# Call a few more functions to show that they are valid
assert without_parameters() is None
assert sum(1, 2) == 3


if __name__ == "__main__":
main()