Commit 46e6c837 by BellCodeEditor

auto save

parent f09a07db
import func
h=func.new_input()
l=func.sum(h)
print(l)
\ No newline at end of file
def new_input():
total = []
while True:
unit= input("请输入:")
if unit== 'q':
break
else:
try:
unit=int(unit)
except:
print('输入整数')
else:
total.append(unit)
return total
def sum(money):
count=0
for i in money:
count= count+i
return count
#a=new_input()
#b=sum(a)
#print(b)
C:\Users\Charles\Desktop\test.txt,
import random #导入模块
a = int(input("想猜几到几的数字(先输入最低):"))
b = int(input("输入你的上限:"))
c = int(input("想要几次机会?:"))
while c>b:
print("怎么能这样!这样还有乐趣吗!重进,重新输入!!!")
while c==b:
print("你这百分百猜对!重进!")
while a > b :
print("你最小比最大大?重进!")
choose = "" #变量
while choose !="退出": #判断
guessesTaken = 0 #猜的次数
print("欢迎!请问你的名字是(别输入天气之子):") #打印
myname = input() #请用户输入ID
while myname == "天气之子":
print("让你别输入,重进吧!!!")
number = random.randint(a,b) #创造一个1~20的数赋值到"number"这个变量
print("嗯,{},我现在在想一个{}~{}之间的数。你一共有{}次机会".format(myname,a,b,c)) #打印
e=c/(b-c)
print("你的正确率是:{},please show time!".format(e))
while guessesTaken <c: #当猜的次数小于6
print("猜猜看:") #打印
guass = int(input()) #请用户输入猜测的数字
guessesTaken += 1 #当用户猜一次就从"13行"的0次加1
if guass < number: #判断:当小于"number"时打印
print("额,太低了。。。")
if guass > number: #判断:当大于"number"时打印
print("太高了。。。")
if guass == number: #判断:当等于"number"时打印
break #等于上一条判断时就结束
if guass == number: #判断:当等于"number"时打印
print("太棒了!你只用了{}次就猜中了!".format(guessesTaken))
choose = input("继续游戏还是退出?:") #将输入的赋值到变量"choose",为"12行"的判断
if guass != number: #当猜的数字不等于"number"时打印
print("真可惜,机会用光了!其实我想的那个数字是:{}".format(number))
choose = input("继续游戏还是退出?:") #将输入的赋值到变量"choose",为"12行"的判断
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment