python 小试一题

Posted on 2019-04-23 19:17  S-skill  阅读(88)  评论(0编辑  收藏  举报

a = 66
count = 1
while  count <=3 :
    b = int(input("猜测这个数字:"))
    if b < a:
        print("猜测的结果小了小了.")
    if b > a:
        print("猜测的结果大了大了.")
    if b == a:
        print("你猜对了.")
        break
    print("你猜了%d次了." % count)
    count += 1
else:
     print("你有点笨.")



解释: "%s" 是数字占位符,传的是数字, 通过count来传数字.

Copyright © 2024 S-skill
Powered by .NET 8.0 on Kubernetes