Friday 21 August 2015

$ python
>>>1/2
>>>1/2.

integer: don't know decimal point
float : know decimal point (comma)


>>> print "hello"

>>> fish = 'tuna'
>>> len (fish)

>>> fish * 10
'tunatunatunatunatunatunatunatunatunatuna'

>>> help(len)
>>> dir()
>>> 1 == 1
True
>>> len(fish) == 4
True
>>> "a" == "a"
True
>>> "a" == "A"
False
>>> "a" != "z"
True
>>> 1 > 0
True
>>> 2 >= 3 (is 2 lebah besar atau sama dengan 3?)
False
>>> -1 < 0
True
>>> "H" in "Hello"
True
>>> "z" in "Hello"
False
>>> "z" not in "hello"
True
>>> x == 4
True
>>> len("")
>>> my_list = ["a", "b", "c"]
>>> len(my_list)
>>> my_list[0]
'a'
>>> my_list[1]
'b'
>>> my_list.append("d")
>>> my_list
['a', 'b', 'c', 'd']
>>>my_list.index("c")
>>> "a" in my_list
True
>>> "z" in my_list
False
>>> my_list[0:2] '[start:not including the second]




No comments:

Post a Comment