#!/usr/bin/env python3 # -*- coding: utf-8 -*- import random a = random.randint(1,100) c = 0 b = 0 while c= a: d = 3 - c print('正确答案比',b,'小,你还有',10-c,'次机会') elif b
1年前 添加回复 0
import random answer = random.randint(1,10) temp = input("我们来玩数字游戏吧~") guess = int(temp) while guess != answer : if guess > answer : print("大了呢,请再输入:") else :
1年前 添加回复 0
import random temp = input("请输入一个数字:") a = int (temp) count=0 while a != 5 and count <3: #and count in range(0,3) count=count+1 temp = input("错了,请再输入一个数字:")
2年前 添加回复 0
import random temp=int(input("请输入我喜欢的数字:")) i=0 rd=random.randint(1,10) while temp!=rd: if temp > rd and i < 3: print ("大了,大了,再猜") i+=1 elif temp < rd and i < 3: print ("小了,小了,再猜") i+=1 temp=int(input("请重新输入:")) if i==3: print ("已经连续猜错3次了") else: print ("猜对了,你真棒。") print ("游戏结束,再见")
3年前 0
模块引入:import module。比如要引用模块randon,就可以在文件最开始的地方用 import randon 来引入。在调用 randon 模块中的函数时,必须这样引用:模块名.函数名(randon.randint)
3年前 0
Admin
import random print('----------小游戏-----------') daan = random.randint(1, 100) print("答案是:" + str(daan)) temp = input("你猜数字是什么:") guess = int(temp) while guess != daan: if g
4个月前 添加回复 0