#猜数字游戏 import random #impor语句导入random模块 guessor=0; print("#"*30) #输出30个”#“(”##############################“)用于装饰输出代码,同下 print("hello! \nwhat is you name?") #“\n”换行 print("#"*30) Myname=input("please enter your name:"…
猜数字游戏 系统生成一个100以内的随机整数, 玩家有6次机会进行猜猜看,每次猜测都有反馈(猜大了,猜小了,猜对了-结束) 6次中,猜对了,玩家赢了. 否则系统赢了 #!/usr/bin/env python import random secret=random.randint(1,100) guess=0 tries=0 print "This game is to guess a number for you!" print " It is a number f…
from sys import exit import random def Arrfor(str): #CONTST = CONTST + 1 artificial = input("请输入1-9之间任意一个数字:") art = int(artificial) #将字符串类型转换为int类型 if art < 1: print("数值不合法!还有",CONTST + "次机会哦") Arrfor(str); if art > 9:…
2015.5.25第一天下载Python IDLE,写个猜数字的小游戏来熟悉这门语言: times=6 letters=[100] for i in range(1,times): a = input("input the number you guess:") try: b = int(a) if isinstance(b,int): if i <5: if int(a) in letters: print("%s is the right answer, you w…
#!/usr/bin/env python #encoding: utf-8 number = 88 for i in range(1,6): num = int(input('gusee number game(5 机会):')) print('第 %s 机会' % (i)) if num >number: print ('big') elif num < number: print ('small') elif num == number: print ('good') break if…