Please help me, in simple terms, understand the "def" function.

View previous topic View next topic Go down

Please help me, in simple terms, understand the "def" function.

Post  johnny-johnson on Sun Apr 19, 2009 10:03 am

I know how to use functions and how to create the calculator program by my self, but I don't understand the function of "def".


Last edited by johnny-johnson on Sun Apr 19, 2009 11:02 am; edited 1 time in total

johnny-johnson
New Guy
New Guy

Posts: 1
Reputation: 0
Join date: 2009-04-19

View user profile

Back to top Go down

Re: Please help me, in simple terms, understand the "def" function.

Post  Xarver on Sun Apr 19, 2009 10:59 am

The def function is something that creates a function,
which is something that repeats an action over and over again.
A function can have parameters:
Code:

def print2(var):
    print var

def add(x, y):
    print x + y

hello = 'Hello!'
add(1, 2) #3
print2(hello) #Hello!

Xarver
Admin
Admin

Posts: 32
Reputation: -1
Join date: 2009-04-17
Location: Somewhere

View user profile http://codegreen.gooforums.com

Back to top Go down

View previous topic View next topic Back to top


Permissions of this forum:
You cannot reply to topics in this forum