本文整理汇总了Python中die.Die.getFaceValue方法的典型用法代码示例。如果您正苦于以下问题:Python Die.getFaceValue方法的具体用法?Python Die.getFaceValue怎么用?Python Die.getFaceValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类die.Die
的用法示例。
在下文中一共展示了Die.getFaceValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from die import Die [as 别名]
# 或者: from die.Die import getFaceValue [as 别名]
def main():
theDie = Die()
count = eval(input("How many times should I roll the die? "))
c1 = 0
c2 = 0
c3 = 0
c4 = 0
c5 = 0
c6 = 0
for i in range(count):
theDie.roll()
val = theDie.getFaceValue()
if val == 1:
c1 = c1 + 1
elif val == 2:
c2 = c2 + 1
elif val == 3:
c3 = c3 + 1
elif val == 4:
c4 = c4 + 1
elif val == 5:
c5 = c5 + 1
elif val == 6:
c6 = c6 + 1
else:
print ("Error - value of die was", val)
c1Percent = float(c1)/count * 100
c2Percent = float(c2)/count * 100
c3Percent = float(c3)/count * 100
c4Percent = float(c4)/count * 100
c5Percent = float(c5)/count * 100
c6Percent = float(c6)/count * 100
print ("Value 1 came up:", c1, "or a percentage of", c1Percent)
print ("Value 2 came up:", c2, "or a percentage of", c2Percent)
print ("Value 3 came up:", c3, "or a percentage of", c3Percent)
print ("Value 4 came up:", c4, "or a percentage of", c4Percent)
print ("Value 5 came up:", c5, "or a percentage of", c5Percent)
print ("Value 6 came up:", c6, "or a percentage of", c6Percent)
示例2: main
# 需要导入模块: from die import Die [as 别名]
# 或者: from die.Die import getFaceValue [as 别名]
def main():
trisha = Die(-5)
## trisha.roll()
print("Trisha", trisha.getFaceValue())
print(trisha)
## sheldon = Die()
## for i in range(10):
## trisha.roll()
## sheldon.roll()
## tValue = trisha.getFaceValue()
## sValue = sheldon.getFaceValue()
## if sValue <= tValue:
## sheldon.setFaceValue(5.5)
## sValue = sheldon.getFaceValue()
## print("Trisha: " + str(tValue), end = " ")
## print("Sheldon: " + str(sValue))
## if tValue > sValue:
## print ("Trisha won!")
## elif tValue == sValue:
## print("Tie")
## else:
## print("Sheldon won!")
print ("Done!")