python definition code example

Example 1: python functions

def myFunction(say): #you can add variables to the function
  print(say)

myFunction("Hello")

age = input("How old are you?")

myFunction("You are {} years old!".format(age))

#this is what you get:

Hello
How old are you?
>>11 #lol my real age actually
You are 11 years old!

Example 2: create function in python

def myFunction():
  print('I am running in a function!')

Example 3: how to use def in python

def functionName(variable):
  //function content

Example 4: python

print("Download Right Now or else Guido Gonna one punch you")

Example 5: python definition

#Use this to shortern a task that you may want to repeat
#Used for making custom commands
def paste(a, b)
	for i in b:
    	print(a)
      
      
while True:
  paste("Python is Cool!!!", 3)
  
#Output:
#Python is Cool!!!
#Python is Cool!!!
#Python is Cool!!!





## - ANOTHER EXAMPLE - ##





happy = "NEUTRAL"

def yes():
  happy="TRUE"
  print("Thank you!")
  
def no():
  happy="FALSE"
  print("That's not nice!")
  
answer=str(input("Do you like my new shoes?   (y/n)  ")
if answer=="yes" or "y" or "Yes" or "Y" or "YES":
  yes()
elif answer=="no" or "n" or "No" or "N" or "NO":
  no()

Example 6: python

# Action Statements

print('hello world')

# Varables

x = 12

y = input("Prompt")

n = True

if n:
	# Some Stuff in here
    
def N(Terms):
    # Some Stuff in here

N(x)

Tags:

Misc Example