s = input("请猜测我心中记住的那个数字是:")
guess = int(s)
if guess == 10:
print("你很聪明呀,一下子就猜对了!")
else:
print("很遗憾!我心中的那个数字是10")
print("游戏结束,不玩啦!")
请猜测我心中记住的那个数字是:10
你很聪明呀,一下子就猜对了!
游戏结束,不玩啦!
s = input("请猜测我心中记住的那个数字是:")
guess = int(s)
if guess == 10:
print("你很聪明呀,一下子就猜对了!")
else:
print("很遗憾!我心中的那个数字是10")
print("游戏结束,不玩啦!")
请猜测我心中记住的那个数字是:10
你很聪明呀,一下子就猜对了!
s1 = input("请猜测我心中记住的那个数字是:")
guess1 = int(s1)
while guess1 != 10:
if guess1 > 10:
print("你猜大啦,往小了猜!^^_^^")
else:
print("嘿,你猜小了,猜大点儿!")
s1 =input("请再猜:")
guess1 = int(s1)
print("终于猜对了")
请猜测我心中记住的那个数字是:15
你猜大啦,往小了猜!^^_^^
请再猜:6
嘿,你猜小了,猜大点儿!
请再猜:10
终于猜对了
import random
r1 = random.randint(1,10)
print(r1)
5
r2 = random.randint(1,10)
print(r2)
5
r3 = random.randint(1,10)
print(r3)
3
secret = random.randint(1,10)
s2 = input("请猜测系统随机生成的数字是:")
guess2 = int(s2)
times = 1
while (guess2 != secret) and (times < 3):
if guess2 > secret:
print("你猜大啦,往小了猜!^^_^^")
else:
print("嘿,你猜小了,猜大点儿!")
s2 = input("请再试试吧:")
guess2 = int(s2)
times = times + 1
if (times <= 3) and (guess2 == secret):
print("你成功地猜到了系统生成的随机数!恭喜")
else:
print("很遗憾,给了三次机会都没猜对,继续加油!")
请猜测系统随机生成的数字是:6
嘿,你猜小了,猜大点儿!
请再试试吧:8
嘿,你猜小了,猜大点儿!
请再试试吧:9
你成功地猜到了系统生成的随机数!恭喜
def sumt(t):
s = 0
while t :
s = s + t
t = t - 1
s = sumt(50)
print(s)
None
def sumt1(t1):
a1 = 0
while t1 :
a1 = a1 + t1
t1 = t1 - 1
return a1
a1 = sumt1(50)
print(a1)
1275
|