Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
py-quickstart/docs/functions/intro-example.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
23 lines (17 sloc)
599 Bytes
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
#!/usr/bin/env python3 | |
# into-example.py | |
# Displaying scope as a call to a variable | |
variable_1 = 70 | |
def add_two(number): | |
result = number + 2 | |
print(f"the square of {number} is: {result}") | |
add_two(variable_1) | |
try: | |
print("testing functions...") | |
# this isn't accessable from outside the square() function | |
print(result) | |
print(base) | |
except NameError: | |
print("These functions aren't in scope") | |
# NOTE!! This code is heavily mentioned in the markdown file "intro-to-functions.md" | |
# if you change it here then you may mess something up there. |