本文整理汇总了Python中Deck.Deck.calcProbability方法的典型用法代码示例。如果您正苦于以下问题:Python Deck.calcProbability方法的具体用法?Python Deck.calcProbability怎么用?Python Deck.calcProbability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deck.Deck
的用法示例。
在下文中一共展示了Deck.calcProbability方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Deck
# 需要导入模块: from Deck import Deck [as 别名]
# 或者: from Deck.Deck import calcProbability [as 别名]
if __name__ == '__main__':
deck = Deck()
# deck.displayDeck()
# we are dealt 7 cards, lets try calculating
# the probabilities of 1-7 cards being same suit
for x in xrange(1, 8):
# simple probab, assuming replacement,
# no joker, and 52 card deck, forget this.
y = x
P = 1
# complex probability, a la compound interest
# no replacement, real life scenario
while y > 0:
y = y - 1
# print 13 - y, 52.0 - y
P = P * deck.calcProbability(deck.cardsInASuit - y, deck.totalCards - y)
print "Getting", x, "cards of same suit", P
# add a joker
jokerDeck = Deck(("Hearts", "Clubs", "Diamonds", "Spades"),
[x for x in xrange(2, 11, 1)],
("Ace", "King", "Queen", "Jack"),
53.0, True)
# for ppt, value in vars(jokerDeck).iteritems():
# print ppt, value
for x in xrange(1, 8):
# simple probab, assuming replacement,
# no joker, and 52 card deck, forget this.
y = x
P = 1
# complex probability, a la compound interest