2015/05/24

Python notes for week 2

Python's string type start and end with ' or ". If you want to show ',
you have to type \' where \ is an escape character. You can also
type "ha"*5 if you would like to show hahahahaha.











print : print a sequence of arguments for a user to read.
Multiple arguments are separated by spaces. For example,
the output of print("hello","there") is hello there.

Consider this case:
1).def area(base, height):
2).' ' ' (number, number)→number
3).Return the area of a triangle with dimensions base and height
4).>>> area(10,5)
5).25.0
6).>>> area(2.5,3)
7).3.75
8).' ' '
9).return base * height / 2

Line 1 called Header. Line 2 called Type Contract.
Line 3 called Description. Line 4~7 called Examples.
Line 9 called Body.