Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

functions in python

#Letters, Nums,
#& underscores
#only, can't	=7  
#start w/ num	|		  _ 5 is the default value if no
# 	  |			|		 |  value is passed
#	  v         v        v
def funcName(param1, param2=5): #The colon terminates func header 
	str(param1) #Typecasting is temparary
    strVar = str(param1) # To make typecast perma, assign to var
    param1 = param2 # 5 is passed to param1 
    return param1 # 5 is returned
#	  ^      ^
#     |		 |_ return value is optional, if no return value, func 
  #Optional		will end returning to func call
  #return

x = funcName(7)
print(x) # prints 5
 
PREVIOUS NEXT
Tagged: #functions #python
ADD COMMENT
Topic
Name
8+2 =