Posted
Filed under 프로그래밍/Python
>>> import random
>>> random.random()
0.90389642027948769

>>> random.randrange(1,7)
6
>>> random.randrange(1,7)
2

>>> range(1,7)
[1, 2, 3, 4, 5, 6]

>>> abc = ['a', 'b', 'c', 'd', 'e']
>>> random.shuffle(abc)
>>> abc
['a', 'd', 'e', 'b', 'c']
>>> random.shuffle(abc)
>>> abc
['e', 'd', 'a', 'c', 'b']

>>> abc
['e', 'd', 'a', 'c', 'b']
>>> random.choice(abc)
'a'
>>> random.choice(abc)
'd'

>>> menu = '쫄면', '육계장', '비빔밥'
>>> random.choice(menu)
'쫄면'
2014/09/30 17:29 2014/09/30 17:29