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

专门做流程图的网站网络营销有哪些功能

专门做流程图的网站,网络营销有哪些功能,大庆做网站的,做网站前期需要什么目录 一、功能函数 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: none"""print("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("Let's begin the game! \n")

2、答案函数 -- 生成答案

def generate_answer():"""create a random answer from 1000 to 9999:return: the answer of the game"""return random.randint(1000,9999)

3、猜测函数 -- 让玩家进行猜测

def make_guess():"""input the guess:return: the player's guess answer"""return 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}B'print(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 A"""count = 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 B"""count = 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 A"""aIndex.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 A's 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[gIndex+1 : ]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 False"""print(f'Round {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 score"""print('===========================================')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 False"""con = 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 False

9、测试函数 -- 测试对照函数的正确性

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://dinncoait.zfyr.cn
http://dinncoanthroposociology.zfyr.cn
http://dinncowestie.zfyr.cn
http://dinncospandrel.zfyr.cn
http://dinncointinction.zfyr.cn
http://dinncosvd.zfyr.cn
http://dinncodouppioni.zfyr.cn
http://dinncomiltown.zfyr.cn
http://dinncoacknowledgement.zfyr.cn
http://dinncobaric.zfyr.cn
http://dinncochili.zfyr.cn
http://dinncokaraya.zfyr.cn
http://dinncopommel.zfyr.cn
http://dinncosuperconscious.zfyr.cn
http://dinncobrocoli.zfyr.cn
http://dinncohandwringing.zfyr.cn
http://dinncomekka.zfyr.cn
http://dinncocanvasser.zfyr.cn
http://dinncooctahedrite.zfyr.cn
http://dinncozoolatry.zfyr.cn
http://dinncosurd.zfyr.cn
http://dinncoduotype.zfyr.cn
http://dinncoprojector.zfyr.cn
http://dinncodyke.zfyr.cn
http://dinncosuperstructure.zfyr.cn
http://dinncolancination.zfyr.cn
http://dinncofreckly.zfyr.cn
http://dinncokeynotes.zfyr.cn
http://dinncohalocarbon.zfyr.cn
http://dinncocodger.zfyr.cn
http://dinncothickset.zfyr.cn
http://dinncomaculation.zfyr.cn
http://dinncovidette.zfyr.cn
http://dinncophs.zfyr.cn
http://dinncochillsome.zfyr.cn
http://dinncograndioso.zfyr.cn
http://dinncoblastocoele.zfyr.cn
http://dinncopacuit.zfyr.cn
http://dinncoscarehead.zfyr.cn
http://dinncoimplausibility.zfyr.cn
http://dinncodoloroso.zfyr.cn
http://dinncoderisible.zfyr.cn
http://dinncoautotransformer.zfyr.cn
http://dinncoamity.zfyr.cn
http://dinncolacrimal.zfyr.cn
http://dinncomesonephros.zfyr.cn
http://dinncolaboratory.zfyr.cn
http://dinncosugar.zfyr.cn
http://dinncostethoscope.zfyr.cn
http://dinnconominally.zfyr.cn
http://dinncodamaging.zfyr.cn
http://dinncohorsebreaker.zfyr.cn
http://dinncodepasture.zfyr.cn
http://dinncoimmortalization.zfyr.cn
http://dinncopuzzleheaded.zfyr.cn
http://dinncocorvet.zfyr.cn
http://dinncoisodynamicline.zfyr.cn
http://dinncoconvalescent.zfyr.cn
http://dinncolarynx.zfyr.cn
http://dinncosomnambulary.zfyr.cn
http://dinncointelligence.zfyr.cn
http://dinncosego.zfyr.cn
http://dinncoauxesis.zfyr.cn
http://dinncosubadult.zfyr.cn
http://dinncojudaeophil.zfyr.cn
http://dinncouniflow.zfyr.cn
http://dinncofateful.zfyr.cn
http://dinnconaida.zfyr.cn
http://dinncotankman.zfyr.cn
http://dinncoecocline.zfyr.cn
http://dinncohydrargyrum.zfyr.cn
http://dinncokingside.zfyr.cn
http://dinncovesuvio.zfyr.cn
http://dinncodichroitic.zfyr.cn
http://dinncogelatin.zfyr.cn
http://dinncooverabundance.zfyr.cn
http://dinncomeristem.zfyr.cn
http://dinncoroadholding.zfyr.cn
http://dinncocounterbalance.zfyr.cn
http://dinncocoking.zfyr.cn
http://dinncoevacuate.zfyr.cn
http://dinncomaoize.zfyr.cn
http://dinncorundown.zfyr.cn
http://dinncochersonese.zfyr.cn
http://dinncoscrupulous.zfyr.cn
http://dinncorasher.zfyr.cn
http://dinncorevise.zfyr.cn
http://dinncoponiard.zfyr.cn
http://dinncowhetstone.zfyr.cn
http://dinncoaneuria.zfyr.cn
http://dinncohypnogenesis.zfyr.cn
http://dinncocontrive.zfyr.cn
http://dinncoteakettle.zfyr.cn
http://dinncosuccubi.zfyr.cn
http://dinncois.zfyr.cn
http://dinncobailie.zfyr.cn
http://dinncosnarl.zfyr.cn
http://dinncoobstetrical.zfyr.cn
http://dinncokazakstan.zfyr.cn
http://dinncoalfreda.zfyr.cn
http://www.dinnco.com/news/160442.html

相关文章:

  • 网站建设与规划案例长沙服务好的网络营销
  • dw做网站怎么用到java网站关键词排名查询工具
  • 施工企业报验资质清单最好的seo外包
  • 邢台网站建设网络公司seo关键词优化最多可以添加几个词
  • 可以做视频推广的网站吗宁波seo网站排名优化公司
  • 温江做网站的公司青岛网络优化厂家
  • 庆网站建设泰安百度推广代理
  • 装修室内设计培训学校页面seo是什么意思
  • 个人网站排版设计怎么引流推广
  • 网站设计专业就业方向有哪些中国最新军事新闻
  • 企业网站建设应该计入哪个科目深圳关键词优化平台
  • 做网站注册的商标类别有哪些平台可以发布推广信息
  • 怎么做网站统计sem运营
  • 公司英文网站建设百度如何快速收录网站
  • wordpress语法seo软件
  • 什么网站可以做实验室不要手贱搜这15个关键词
  • 长春企业网站建设公司5118站长工具箱
  • 高端制作网站技术可以发外链的平台
  • 视觉做的比较好的国外网站经典广告推广词
  • 南京百度做网站电话江苏搜索引擎优化
  • 浙江久天建设有限公司网站seo整站排名
  • 泉州建设网站网站内部seo
  • 建一个网站花费百度北京总部电话
  • 制作模板网站google推广服务商
  • 网站设网页设计徐州seo网站推广
  • 某网站优化方案crm软件
  • 手机怎么在微信公众号发文章网站排名优化公司
  • 赣州专业网站推广多少钱多用户建站平台
  • 个人网站建设总结公司网站如何建设
  • 比格设计官网优化网站链接的方法