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

政务网站建设浙江升级wordpress5.0无法发布文章

政务网站建设浙江,升级wordpress5.0无法发布文章,济南浩辰网站建设公司怎么样,企业建设网站的好处有哪些目录 一、功能函数 1、说明函数 -- 对游戏玩法及设置进行说明 2、答案函数 -- 生成答案 3、猜测函数 -- 让玩家进行猜测 4、对照函数 -- 将答案和猜测进行对照 4.1 A函数 4.2 B函数 5、结果函数 -- 判断得到结果或继续猜测 6、时间函数 -- 判断一局游戏所用时间 7、打…目录 一、功能函数 1、说明函数 -- 对游戏玩法及设置进行说明 2、答案函数 -- 生成答案 3、猜测函数 -- 让玩家进行猜测 4、对照函数 -- 将答案和猜测进行对照 4.1 A函数 4.2 B函数 5、结果函数 -- 判断得到结果或继续猜测 6、时间函数 -- 判断一局游戏所用时间 7、打印函数 -- 显示每局的成绩 8、下局函数 -- 是否进行下一局游戏 9、测试函数 -- 测试对照函数的正确性 二、主程序 -- 两个while循环 一、功能函数 1、说明函数 -- 对游戏玩法及设置进行说明 def notification():write some information about the game -- tell the player how to play:return: noneprint(Guess the number from 1000 to 9999~)print(A means the number of the data and its location which are correct)print(B means the number of the data is correct but the location is wrong)print(for example, the right answer is 1234, your guess is 1245, then it will show 2A1B)print((Give you another example:9527 and 9572 : 2A2B))print(Lets begin the game! \n) 2、答案函数 -- 生成答案 def generate_answer():create a random answer from 1000 to 9999:return: the answer of the gamereturn random.randint(1000,9999) 3、猜测函数 -- 让玩家进行猜测 def make_guess():input the guess:return: the players guess answerreturn int(input(Plz input your guess:)) 4、对照函数 -- 将答案和猜测进行对照 def check_guess(answer, guess):Get the result -- how many numbers and locations are right:param answer: The right answer which was created by the function of generate_answer:param guess: The input of player:return: (number)A(number)B -- for example -- 4A0B -- you got the right answerA means both the number and location are correctB means only the number is correct(despite the A)a_num check_a(answer, guess)b_num check_b(answer, guess)result f{a_num}A, {b_num}Bprint(result)return result 4.1 A函数 def check_a(answer, guess):check the right number and location -- for example, 9527 guess 9572, return 2:param answer: The right answer which was created by the function of generate_answer:param guess: The input of player:return: the number of Acount 0ansStr str(answer)gueStr str(guess)for index, char in enumerate(gueStr):if (ansStr[index] char):count 1return count 4.2 B函数 一开始想直接用if char in ansstr指令但想到有9527和9522得到1b的情况。 --- 因此引入了aIndex变量使用guestr.index(char) not in aIndex作为额外补充条件但出现了答案为1333和猜测3833出现3B的情况。 -- 经过检查发现index函数只能查到字符串中某字符出现的第一个位置相当于无论是第一个3还是第二个3还是第三个三使用guestr.index(char)指令只能获得第一个3所在的位置因此三个三使程序运行了三次第一个三不在aindex位置的代码。 为了解决这种情况想到在一开始检测A的情况时就将答案和猜测中A的位置上的数字替换成别的字母这样在检测B的个数时免受A位置的干扰。为了防止1333和3833出现3b的情况在第一个3出现的时候就先计算一次再将这个3替换成别的字母这样在第二个3出现的时候由于第一个三已经被替换成了字母使用index函数时第二个3的位置就可以被检测到。 def check_b(answer, guess):check the number:if the number is correct but the location is wrong, then the num of b add 1only can be compared with those not belong to A:param answer: The right answer which was created by the function of generate_answer:param guess: The input of player:return: the number of Bcount 0ansStr str(answer)gueStr str(guess)aIndex [] # save the index of Arepeat []for index, char in enumerate(ansStr):if (gueStr[index] char):remove the number of AaIndex.append(index)gueStr gueStr[:index] str.replace(gueStr[index], char, a) gueStr[index 1:]ansStr ansStr[:index] str.replace(ansStr[index], char, b) ansStr[index 1:]for char in ansStr:if the number is in the B -- if the index of the number is not in As indexthe number of B add 1and replace the number to a (because the function index always count the location of the first char)if(char in gueStr):gIndex gueStr.index(char)count 1gueStr gueStr[:gIndex] str.replace(gueStr[gIndex],char, a) gueStr[gIndex1 : ]return count 5、结果函数 -- 判断得到结果或继续猜测 def process_result(guess_count,guess,result):Handle the result:if win(4A0B), return True, or return False:param guess_count: the guess chances the player has used:param guess: the answer of the player(guess):param result: (number)A(number)B:return: True or Falseprint(fRound {guess_count}, Your guess is: {guess}, And the result is: {result})if result 4A, 0B:print(Yeah, you win!!!~~~~)return Trueelse:print(Try again!)return False 6、时间函数 -- 判断一局游戏所用时间 def checkTime(begin_time):Record the time of guessing -- from beginning until the right answer:param begin_time: when the player began a new game:return: the time the player used in one game (seconds)finish_time time.time()Time finish_time - begin_timereturn Time 7、打印函数 -- 显示每局的成绩 def show_score(score):print the score(the round of the game, how many chances the player used to guess the right answer, and the total time):param score: the score the player got:return: none, just for printing the scoreprint()print(ROUND.ljust(10), CHANCE.ljust(10), TIME.ljust(10))for sc in score:cycle str(sc[0]).ljust(10)guess str(sc[1]).ljust(10)time str(sc[2]).ljust(10)print(cycle,guess,time) 8、下局函数 -- 是否进行下一局游戏 def should_continue():ask for continue -- if y or Y, then begin a new game, or end the running:return: True or Falsecon input(Do you wanna start a new game? if yes, input y or Y)if(con y or con Y):print(Thank u for another game, hope you can enjoy!)return Trueelse:print(Thank u for playing, have a nice day! Goodbye~~~~)return False9、测试函数 -- 测试对照函数的正确性 if __name__ __main__:only when testing the gueFun, the function will runfor checking if the logic is correct# auto judgement a numberassert (check_a(9527, 9522) 3)assert (check_a(9572, 9527) 2)assert (check_a(9527, 9342) 1)assert (check_a(1234, 5678) 0)assert (check_a(1111, 1211) 3)assert (check_b(1234, 4321) 4)assert (check_b(9527, 5923) 2)assert (check_b(9527, 9522) 0)assert (check_b(1333, 3833) 1)assert (check_b(1111, 1311) 0)assert (check_b(9269, 6266) 0)# if wanna know the functions function, then use this: # print(bmi.__doc__) 二、主程序 -- 两个while循环 第一个while循环控制是否进行下一局游戏 包括对一局游戏的变量初始化记录开始时间及在游戏结束后打印战绩 第二个while循环控制一局游戏的全部操作 生成随机答案输入猜测判断猜测是否正确给出提示生成结果
http://www.w-s-a.com/news/580392/

相关文章:

  • 电线电缆技术支持中山网站建设广告设计培训学校有哪些
  • 如何禁止通过ip访问网站wordpress无法调用主题布局和图片
  • 江西建设工程信息网站重庆网站推广大全
  • 南浔区住房城乡建设局网站网页设计基础学什么
  • 萧山做网站的企业网站建设 西安
  • 江西省城乡建设厅网站百度站长资源平台
  • 本地搭建linux服务器做网站免费查企业信息查询
  • 电商网站建设与运营网上购物哪个网站最好
  • 做app做网站从何学起网站设计需要什么证
  • 设计网站最重要的是要有良好的短网址还原
  • 大连建设银行招聘网站做seo是要先有网站吗
  • 中山做网站的wordpress建站教程百科
  • 湛江专业网站制作做网站需要工具
  • 做音箱木工网站吉林平安建设网站
  • 品牌网站建设咨询灯光设计网站推荐
  • 温州网站运营打开百度一下网页版
  • 网站有情链接怎么做住房公积金个体工商户
  • 内蒙古网站开发网站开发验收资料
  • 温州网站建设首选国鼎网络网络营销方法可分为两类
  • 做张家界旅游网站多少钱企业推广网络营销
  • 代做毕设网站推荐广东手机微信网站制作
  • 福州建设工程质量监督网站专业做公司宣传网站的
  • 百度云建站教程网站工程师是做什么的
  • 手机在线制作网站一级消防工程师考试试题及答案
  • 网站设计的需求网页制作教程和素材
  • 徐州网站建设 网站推广WordPress 文章编辑
  • 做什么网站比较受欢迎软件商店下载安装2023版本最新
  • 做ip资讯的网站怎么在wordpress中套用同行网页
  • 医院网站如何备案东莞优化公司收费
  • 罗村网站开发适合ps做图的素材网站有哪些