Skip to content
Permalink
689d0e07e4
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
23 lines (17 sloc) 599 Bytes
#!/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.