Skip to content

Commit

Permalink
Update python-5.md
Browse files Browse the repository at this point in the history
  • Loading branch information
denten committed Jun 7, 2016
1 parent 84fbfed commit db33835
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tutorials/python/python-5.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
# Functions
# Methods & Functions

[https://docs.python.org/2/library/functions.html][1]

## Methods

> A method is a piece of code that is called by a name that is associated with an object.
[A.E.](http://stackoverflow.com/questions/155609/difference-between-a-method-and-a-function]

[1]: https://docs.python.org/2/library/functions.html

```
# what can a cat do?
# in iPython tab after the period to see what functions are attached to the object
a = 'hello'
b = 7
c = [ 'apple', 'orange', 'banan', '32']
# or use iPython built-in introspection
# a? b? c?
type(a)
type(b)
type(c)
# what can we DO with ints, strings, and lists?
# tab here
a.
b.
c.
```

## Functions

```
# Make your own verbs
def print_twice(bob):
print(bob)
print(bob)
Expand All @@ -19,4 +43,6 @@ a = "hello world!"
print_twice(a)
# pass data from one function to another
```

0 comments on commit db33835

Please sign in to comment.