#!/usr/local/bin/python3
import random
bot=int(input('Set range bottom\n'))
top=int(input('Set range top\n'))
rand=random.randint(bot,top)
print ('Random number in ['+str(bot)+','+str(top)+'] generated!')
num=int(input('###Guess the number###\n'))
cnt=1
while (num!=rand):
if (num<rand):
print('*_* Lower than the answer')
else:
print('T_T Higher than the answer')
num=int(input('###Guess the number###\n'))
cnt=cnt+1
print('^_^ You get the answer with [%d] times'%cnt)
#!/usr/local/bin/python3
import time
num = int(input('有多少组玩家\n'))
guessWord = []
correct = []
#定义列表,num+10是不想让guessWord下标不合法
for i in range(0,num+10):
guessWord.append(0)
correct.append(0)
wordNum=10
guessWord[0] = ['打情骂俏','海绵宝宝','娇媚','金鸡独立','狼吞虎咽','睡眼朦胧','鹤立鸡群','手舞足蹈','卓别林','穿越火线']
guessWord[1] = ['眉飞色舞','英雄联盟','扭秧歌','偷看美女','大摇大摆','回眸一笑','市场营销','大眼瞪小眼','自恋','处女座']
guessWord[2] = ['狗急跳墙','捧腹大笑','目不转睛','愁眉苦脸','左顾右盼','宫保鸡丁','升国旗','暗恋','臭袜子','趁火打劫']
flag='n'
for i in range(0,num):
start = time.time()
for k in range(0,wordNum):
#显示词语
print (('%d.%s')%(k+1,guessWord[i][k]))
flag = input('请答题,答对请输入y,跳过请输入任意键')
end = time.time()
sec = end-start
#统计用时
if (110<=sec<=120):
print ('还有10秒钟')
if (sec>=120):
print ('时间到!游戏结束')
break
if (flag=='y'):
correct[i]=correct[i]+1
continue
else:
continue
str_temp=('第%d组答对数目:%d') % (i+1,correct[i])
print (str_temp)
#!/usr/local/bin/python3
import random
from spyword import spyword
num=int(input('请输入玩家数(至少为3)\n'))
#卧底玩家
spy=random.randint(0,num-1)
#随机产生词语 定义词语列表 计算玩家票数的列表 统计死亡玩家的列表
list_rand=spyword.popitem()
word=[]
cnt=[]
dead=[]
#给三个列表赋值
for i in range(0,num):
word.append('a')
cnt.append(0)
dead.append(num+2)
#给玩家词语 其中print是调试用的,sanmeVote是出现相同票数的标志,spyWin是卧底胜利的判决条件
for i in range(0,num):
if (i==spy):
word[i]=str(list_rand[1])
else:
word[i]=str(list_rand[0])
print (word[i])
sameVote=0
spyWin=0
#游戏开始
for x in range(0,num-1):
for k in range(0,num):
if ((k not in dead) & (sameVote==0)):
print ('%d号玩家发言时间'%(k+1))
print ('发言环节结束')
#将各位玩家的票数置0
for j in range(0,num):
if (j not in dead):
cnt[j]=0
for j in range(0,num):
if (j not in dead):
vote2p=int(input('请%d号玩家投票'%(j+1)))-1
cnt[vote2p]=cnt[vote2p]+1
sameVote=0
for y in range(0,num):
if((cnt[y]==max(cnt)) & (y!=cnt.index(max(cnt)))):
print ('不止一位玩家得到最高票数,请这些玩家重新发言')
sameVote=1
if (sameVote==0):
dead[x]=cnt.index(max(cnt))
if (dead[x]==spy):
print ('卧底得到最多票数,游戏结束')
spyWin=1
break
print ('%d号玩家被冤死!'%(dead[x]+1))
#游戏结束
if(spyWin==0):
print ('只剩两名玩家,卧底胜利!')
from spyword import spyword
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有