当前位置: 首页 > news >正文

济南网站建设公司按需定制保险网站建设的目标

济南网站建设公司按需定制,保险网站建设的目标,吾爱源码,百度短链接在线生成器题目 当输入单人赢球概率不在1到0之内,提示重新输入每局比赛一方比分大于21,且与另一方分差至少为2,则该场胜利者为得分高者,否者得分高者仅为该局胜利者每场比赛三局两胜,先赢两场为胜利者 代码 import random# 判…

题目

  1. 当输入单人赢球概率不在1到0之内,提示重新输入
  2. 每局比赛一方比分大于21,且与另一方分差至少为2,则该场胜利者为得分高者,否者得分高者仅为该局胜利者
  3. 每场比赛三局两胜,先赢两场为胜利者

代码

import random# 判断是否为数字
def is_number(v):if v.isdigit():return float(v)else:try:if float(v):return float(v)else:return Falseexcept ValueError:return False# 获取单人成绩 随机数    
def getr(p):s = random.triangular(0, p)*100s = round(s)return s# 获取单局结果
def def_result_item(ap,bp):a_s,b_s = getr(ap),getr(bp)# a_s,b_s = 7,11max_s = 21s_list = {"a":a_s,"b":b_s}ss_list = sorted(s_list.items(), key=lambda x:x[1], reverse=True)k0,v0 = ss_list[0]k1,v1 = ss_list[1]r = Falseif v1!=v0:if v0>=21 and v0-v1>=2:r=k0else:print(ss_list)return Falsedata = {"list":ss_list,"r":r}return data#获取单场结果
def get_result(ap,bp):last_r = Falseresult_list = {}result = ""result_list =[]for i in range(1,3):data = def_result_item(ap,bp)if not data:continuer = data.get("r")list_v = data.get("list")result_data = {"index":i,'r':r,"list":list_v}result_list.append(result_data)if r:last_r = rbreak;k,v= list_v[0]result += k+","ca = result.count('a')cb = result.count('b')if ca==2:last_r =  'a'breakif cb==2:last_r = 'b'breakdata = {"list":result_list,"r":last_r}return data#调用    
def get_inputs(times):pa = input("输入单球获胜概率")while True:pa=is_number(pa)if pa:if not (pa>0 and pa<1):pa = input("输入错误,请重新输入")else:breakelse:pa = input("输入数字,请重新输入")pb=round(1-pa,2)print("a p:{0} b p:{1} itmes:{2}".format(pa,pb,times))ra = 0rb = 0for i in range(0,times):print("time:{0}".format(i))result = get_result(pa,pb)r =  result.get("r")list_v = result.get("list")print(list_v)if r =="a":ra+=1if r =="b":rb+=1print("ra:{0} tb:{1}".format(ra,rb))#比赛50次
get_inputs(50)

输出

输入单球获胜概率 aa
输入数字,请重新输入 0.4
a p:0.4 b p:0.6 itmes:50
time:0
[{'index': 1, 'r': 'b', 'list': [('b', 40), ('a', 24)]}]
time:1
[{'index': 1, 'r': 'a', 'list': [('a', 37), ('b', 4)]}]
time:2
[{'index': 1, 'r': 'b', 'list': [('b', 27), ('a', 13)]}]
time:3
[{'index': 1, 'r': False, 'list': [('b', 18), ('a', 15)]}, {'index': 2, 'r': 'a', 'list': [('a', 34), ('b', 22)]}]
time:4
[{'index': 1, 'r': 'b', 'list': [('b', 46), ('a', 36)]}]
time:5
[{'index': 1, 'r': 'a', 'list': [('a', 23), ('b', 16)]}]
time:6
[{'index': 1, 'r': 'b', 'list': [('b', 38), ('a', 19)]}]
time:7
[{'index': 1, 'r': 'b', 'list': [('b', 23), ('a', 13)]}]
time:8
[{'index': 1, 'r': 'b', 'list': [('b', 32), ('a', 22)]}]
time:9
[{'index': 1, 'r': 'b', 'list': [('b', 33), ('a', 30)]}]
time:10
[{'index': 1, 'r': False, 'list': [('b', 20), ('a', 18)]}, {'index': 2, 'r': 'b', 'list': [('b', 51), ('a', 10)]}]
time:11
[{'index': 1, 'r': 'b', 'list': [('b', 40), ('a', 22)]}]
time:12
[{'index': 1, 'r': 'b', 'list': [('b', 41), ('a', 5)]}]
time:13
[{'index': 1, 'r': 'b', 'list': [('b', 25), ('a', 18)]}]
time:14
[{'index': 1, 'r': False, 'list': [('a', 17), ('b', 11)]}, {'index': 2, 'r': 'b', 'list': [('b', 40), ('a', 8)]}]
time:15
[{'index': 1, 'r': 'a', 'list': [('a', 27), ('b', 17)]}]
time:16
[('a', 33), ('b', 33)]
[{'index': 2, 'r': 'a', 'list': [('a', 26), ('b', 22)]}]
time:17
[{'index': 1, 'r': 'b', 'list': [('b', 34), ('a', 23)]}]
time:18
[{'index': 1, 'r': 'a', 'list': [('a', 22), ('b', 7)]}]
time:19
[{'index': 1, 'r': 'a', 'list': [('a', 28), ('b', 25)]}]
time:20
[{'index': 1, 'r': 'b', 'list': [('b', 27), ('a', 10)]}]
time:21
[{'index': 1, 'r': 'b', 'list': [('b', 34), ('a', 11)]}]
time:22
[('a', 28), ('b', 28)]
[{'index': 2, 'r': 'b', 'list': [('b', 43), ('a', 6)]}]
time:23
[{'index': 1, 'r': 'b', 'list': [('b', 24), ('a', 17)]}]
time:24
[{'index': 1, 'r': 'b', 'list': [('b', 39), ('a', 23)]}]
time:25
[{'index': 1, 'r': 'b', 'list': [('b', 46), ('a', 25)]}]
time:26
[{'index': 1, 'r': 'b', 'list': [('b', 44), ('a', 11)]}]
time:27
[{'index': 1, 'r': 'b', 'list': [('b', 44), ('a', 6)]}]
time:28
[{'index': 1, 'r': 'b', 'list': [('b', 48), ('a', 8)]}]
time:29
[{'index': 1, 'r': 'b', 'list': [('b', 41), ('a', 32)]}]
time:30
[{'index': 1, 'r': 'b', 'list': [('b', 30), ('a', 10)]}]
time:31
[{'index': 1, 'r': 'b', 'list': [('b', 39), ('a', 14)]}]
time:32
[{'index': 1, 'r': 'b', 'list': [('b', 46), ('a', 17)]}]
time:33
[{'index': 1, 'r': 'a', 'list': [('a', 34), ('b', 6)]}]
time:34
[{'index': 1, 'r': 'b', 'list': [('b', 34), ('a', 16)]}]
time:35
[{'index': 1, 'r': 'b', 'list': [('b', 28), ('a', 16)]}]
time:36
[{'index': 1, 'r': 'b', 'list': [('b', 49), ('a', 33)]}]
time:37
[{'index': 1, 'r': 'b', 'list': [('b', 31), ('a', 5)]}]
time:38
[{'index': 1, 'r': 'b', 'list': [('b', 24), ('a', 11)]}]
time:39
[{'index': 1, 'r': 'a', 'list': [('a', 22), ('b', 17)]}]
time:40
[{'index': 1, 'r': 'b', 'list': [('b', 28), ('a', 20)]}]
time:41
[{'index': 1, 'r': 'b', 'list': [('b', 45), ('a', 20)]}]
time:42
[{'index': 1, 'r': 'b', 'list': [('b', 24), ('a', 18)]}]
time:43
[{'index': 1, 'r': 'b', 'list': [('b', 46), ('a', 27)]}]
time:44
[{'index': 1, 'r': False, 'list': [('a', 11), ('b', 8)]}, {'index': 2, 'r': 'b', 'list': [('b', 34), ('a', 13)]}]
time:45
[{'index': 1, 'r': 'a', 'list': [('a', 29), ('b', 26)]}]
time:46
[{'index': 1, 'r': 'a', 'list': [('a', 21), ('b', 15)]}]
time:47
[{'index': 1, 'r': 'b', 'list': [('b', 29), ('a', 19)]}]
time:48
[{'index': 1, 'r': 'b', 'list': [('b', 41), ('a', 34)]}]
time:49
[{'index': 1, 'r': False, 'list': [('a', 20), ('b', 19)]}, {'index': 2, 'r': False, 'list': [('b', 16), ('a', 14)]}]
ra:11 tb:38

http://www.dtcms.com/a/438889.html

相关文章:

  • 深入剖析:boost::intrusive_ptr 与 std::shared_ptr 的性能边界和实现哲学
  • 聊城制作手机网站公司网站建设需要的条件
  • SQL 子查询与多表 JOIN 用法大全(速查版)
  • Leetcode 239. 滑动窗口最大值 优先队列 / 双向单调队列
  • Nacos 工作原理及流量走向
  • 夏津网站建设茂名企业建站程序
  • OSPF 单区域实验 概念及题目
  • 建立一个门户网站WordPress域名后问号英文
  • 自上而下VS自下而上:设计哲学全解
  • 【开题答辩全过程】以 SpringCloud家乡美旅行交流博客平台为例,包含答辩的问题和答案
  • 2015优先中文公司官网wordpress模板
  • 国外优秀企业网站网络空间的竞争归根结底是
  • 哪些外贸网站可以做soho求网站2021给个网址
  • 2022年网站能用的兰州企业网站制作
  • 网页设计与网站建设实战大全推荐好的网站或网页
  • 查看网站是否做百度推广如果在网上接网站建设项目
  • 如何用源码搭建网站源码网站搭建规划
  • 【办公类-117-01】20250924通义万相视频2.5——三个小人(幼儿作品动态化)
  • PBS, 以太坊的棘刺雕猴
  • 【未来】智能体互联时代的商业模式变化和挑战:从HOM到AOM
  • 域名免费注册网站网站模板凡建站
  • 关键词挖掘站长c 教程如何做网站
  • 爬坑 10 年总结!淘宝全量商品接口实战开发:从分页优化到数据完整性闭环
  • 网站的设计制作流程网络营销的流程
  • 网站改版计划珠宝 网站模板
  • LangChain源码分析(九)- 向量存储
  • 鸿蒙NEXT系列之探索鸿蒙PC
  • 大岭山镇网站建设公司酷家乐线下培训班
  • 【C++实战(66)】从0到1:C++图形化编程实战之Qt基础入门
  • LeetCode199