summaryrefslogtreecommitdiff
path: root/functions_.txt
diff options
context:
space:
mode:
authorShantanu Choudhary2010-04-26 10:34:06 +0530
committerShantanu Choudhary2010-04-26 10:34:06 +0530
commitc1aac424a67f130545c53426ca7a6bd305d37b7e (patch)
tree7c03a7994fdecc77eb954d9001005824b412c7a3 /functions_.txt
parente4626f91614d78f4b2cdeef76634c78c0843dc6c (diff)
parentb34910f6900688651d2d5122c1d5d52a8f174969 (diff)
downloadst-scripts-c1aac424a67f130545c53426ca7a6bd305d37b7e.tar.gz
st-scripts-c1aac424a67f130545c53426ca7a6bd305d37b7e.tar.bz2
st-scripts-c1aac424a67f130545c53426ca7a6bd305d37b7e.zip
Merged branches.
Diffstat (limited to 'functions_.txt')
-rw-r--r--functions_.txt13
1 files changed, 13 insertions, 0 deletions
diff --git a/functions_.txt b/functions_.txt
new file mode 100644
index 0000000..b0d8e67
--- /dev/null
+++ b/functions_.txt
@@ -0,0 +1,13 @@
+While we have talked about how you can do simple tasks in Python we haven't started to talk about how you can organize your code . One of the first techniques we use to break a task into relatively independent subtask . These can share data with other parts of the program . These code blocks clubbed together are called functions or subroutines .
+
+def keyword in Python is used to define a function.
+Arguments are local to a function , i.e you can access the arguments only in a particular function in other places it shall raise a Name error .
+
+One of the great things about python is that a function can return multiple values . Essentialy it does it by packing the multiple values in a tuple .
+
+Lets look at how to write functions by writing one out .
+
+We have given the function the name signum . Essentially what it does is that based on whether the no is 0 , negative or positive , it returns 0 , -1 and +1 respectively . In this case it recieves value of the no in variable r .
+
+In the beginning of the function you can see a triple quoted string . This is called a docstring . You can write some documentation related to your function. In this you can have the function parameters and what it returns . A python function returns a value by using the keyword return .
+