PHPst
0
Q:

def python

def example():			#This defines it
  print("Example.")		#This is the defined commands

example()				#And this is the commands being run
17
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!
18
def name_function(parameter list):
      instruction block
6
def your_function(arg1, arg2, arg3):
  do_something
  do_something_else

#to call the function (make it run):

your_function(something, something, something)
2
def myFunction():
  print('I am running in a function!')
14
def function():
  print('This is a basic function')
  
function()
// Returns 'This is a basic function'

def add(numA, numB):
  print(numA+numB)
  
add(1,2)
// Returns 3

def define(value):
  return value

example = define('Lorem ipsum')
print(example)
// Returns 'Lorem ipsum'

6
def functionName(variable):
  //function content
7
def nameOfFunction(something):
  	return something
6
def my_function(a,b=1,c=2,verbose=True):
  x=a+b+c
  if verbose:
    print('Just wanted to tell you x=%d' %x)
  return x

n=my_function(3)
4

  def my_function(fname, lname):
  print(fname + " " + lname)


  my_function("Emil", "Refsnes") 
3
x ="world"

def myfunc():
    global x
    x ="hello"
myfunc()
print(x)

0
for i in range(3):
    scores = int(input("Enter scores: ")
    test = scores / 3
print "Total average grade: " + str(test)        
-2

New to Communities?

Join the community