Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

define and call function in python

x = 5
print('Hello')
# Here you define the function, start with def key word ends with colon
# The block of code of the function should be indented
def print_lyrics():
    print("I'm a lumberjack, and I'm okay.")
    print("I sleep all night and I work all day.")

print('Yo')
# Here we call or invoke the function
print_lyrics()
x = x+2
print(x)
Source by www.py4e.com #
 
PREVIOUS NEXT
Tagged: #define #call #function #python
ADD COMMENT
Topic
Name
7+7 =