设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
查看: 12551|回复: 1
打印 上一主题 下一主题

小白求教~这个应该怎么改啊

[复制链接]

1

主题

0

好友

7

积分

新手上路

Rank: 1

跳转到指定楼层
楼主
发表于 2019-8-14 16:48:01 |只看该作者 |倒序浏览
import random
secert = random.randint(1,100)
guess = 0
tries = 0
print("AHOY!I AM THE DREAD PIRATE ROBERS,AND I HAVW A SECRET!")
print("IT IS A NUMBER FROM 1 TO 99. I WILL GIVE YOU 6 TRIES.")
while guess!= secert and tries < 6:
    guess = int(input("WHAT IS YER GUESS?"))
    if guess<66:
        print("TOO LAW")
    elif guess>66:
        print("TOO HIGH")
    tries = tries + 1
    if guess==66:
        print("YOU FOUND MY SECERT!")
    else:
        print("NO MORE GUESSES! BETTER LUCK NEXT TIME, MATEY!")
        print("THE SECERT NUMBER WAS",66)
有这么几个问题:1.不知道这个程序写的对不对,反正运行不出结果
2.想知道怎么改3.超级超级小白,希望大神解说的时候尽量白话
回复

使用道具 举报

0

主题

0

好友

6

积分

新手上路

Rank: 1

沙发
发表于 2019-8-17 23:23:50 |只看该作者
import random
# secert是1-100之间的随机数
secert = random.randint(1,100)
guess = 0
tries = 0
print("AHOY!I AM THE DREAD PIRATE ROBERS,AND I HAVW A SECRET!")
print("IT IS A NUMBER FROM 1 TO 99. I WILL GIVE YOU 6 TRIES.")
# tries<6 来统计输入的数(guess)是否和secert的值相等
while guess!= secert and tries < 6:
    print('secert:', secert)
    guess = int(input("WHAT IS YER GUESS?"))
    if guess<secert:
        print("TOO LAW")
    elif guess>secert:
        print("TOO HIGH")
    elif guess==secert:
        print("YOU FOUND MY SECERT!")
    # 输入guess不等于secert时,tries的值加1
    tries = tries + 1
print("NO MORE GUESSES! BETTER LUCK NEXT TIME, MATEY!")
print("THE SECERT NUMBER WAS", secert)
# 加两条注释和一个print语句,你看一下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-11-26 01:21 , Processed in 0.014480 second(s), 20 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部