Skip to content

Instantly share code, notes, and snippets.

@kavinyao
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kavinyao/232c292f1bd8c2dd3c53 to your computer and use it in GitHub Desktop.
Save kavinyao/232c292f1bd8c2dd3c53 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from enum import Enum
from random import choice
def 做(事情):
事情()
def 如果(条件成立, 那么做, 动作1, 不然就做, 动作2):
if 条件成立:
做(动作1)
else:
做(动作2)
def 重复(次数, 事情):
for _ in range(次数):
做(事情)
随机选 = choice
怒吼 = print
十次 = 10
那么 = 不然的话就 = None
def 带伞():
怒吼('我带伞啦!!!')
def 裸奔():
怒吼('裸奔好爽!!!')
class 硬币(Enum):
正面 = 1
反面= 0
def 抛硬币():
return 随机选([硬币.正面, 硬币.反面])
def 实验():
明天下雨 = 抛硬币() == 硬币.正面
如果(明天下雨, 那么, 带伞, 不然的话就, 裸奔)
重复(十次, 实验)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment