'''hey everyone it is a basic game code using random . in this game computer will randomly chose an number from 1 to 100 and players will haveto guess that which number it is and game will tell him on every guss whether his/her guess is smaller or bigger than the chosen number. it isa multi player game so it can be played with many players there is no such limitations of user till the size of list. if any one wants to modifythis game he/she is most welcomed.Thank you'''import osimport randomplayers=[]score=[]print("\n\tRandom Number Game\n\nHello Everyone ! it is just a game of chance in which you have to guess a number"" from 0 to 100 and computer will tell whether your guess is smaller or bigger than the acctual number chossen by the computer . ""the person with less attempts in guessing the number will be winner .")x=input()os.system('cls')n=int(input("Enter number of players : "))print()for i in range(0,n):name=input("Enter name of player : ")players.append(name)os.system('cls')for i in range(0,n):orignum=random.randint(1,100)print(players[i],"your turn :",end="\n\n")count=0while True :ch=int(input("Please enter your guess : "))if ch>orignum:print("no! number is smaller...")count+=1elif ch==orignum:print("\n\n\tcongrats you won")breakelse :print("nope ! number is large dude...")count+=1print(" you have taken", count+1,"attempts")x=input()score.append(count+1)os.system('cls')print("players :\n")for i in range(0,n):print(players[i],"-",score[i])print("\n\nwinner is :\n")for i in range(0,n):if score[i]==min(score):print(players[i])x=input()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。