高分和保持得分

发布于 2025-01-24 08:26:47 字数 642 浏览 0 评论 0原文

#这是一个用于循环的循环,可以使玩家玩谜语游戏的得分 #它运行并循环,但无法正确计算得分。 #有6个谜语和3轮。 #say我得到4/6正确的分数是20,但它显示为3.0。导入数学功能时,如何获得精确的答案?

for i in range(6):
        print(riddles[i])  
        #
        userchoice = input("Enter A, B, C, or D: ")
        if userchoice.upper() == answers[i]:
            print("That's Correct")
            score += 5
            print(f" {score}")
        else:
            print("That's Incorrect")
            
            score -= 1
            
            print(f"{score}")

        total = total + int(score)
        
    highScoreEasy = print(f"Here is your score: {int(total/score)} !!!!!")
    print()

#This is a for loop to get the score of a player playing a riddle game
#It runs and loops but it's not calculating the score properly. #There're 6 riddles and 3 rounds. #Say I get 4/6 correct my score is 20 but it's displaying 3.0 instead. how do I get a precise answer while importing the math function?

for i in range(6):
        print(riddles[i])  
        #
        userchoice = input("Enter A, B, C, or D: ")
        if userchoice.upper() == answers[i]:
            print("That's Correct")
            score += 5
            print(f" {score}")
        else:
            print("That's Incorrect")
            
            score -= 1
            
            print(f"{score}")

        total = total + int(score)
        
    highScoreEasy = print(f"Here is your score: {int(total/score)} !!!!!")
    print()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩起发的微风 2025-01-31 08:26:47

不应该只是简单的总和吗?

riddles = []
answers = []

riddle_score = 5
total = len(riddles) * riddle_score
score = 0

for i, riddle in enumerate(riddles):
    print(riddle)

    userchoice = input("Enter A, B, C, or D: ")
    if userchoice.upper() == answers[i]:
        print("That's Correct")
        score += riddle_score
    else:
        print("That's Incorrect")

print(f"Here is your score: {score}/{total}!")

Shouldn't it just be a simple sum?

riddles = []
answers = []

riddle_score = 5
total = len(riddles) * riddle_score
score = 0

for i, riddle in enumerate(riddles):
    print(riddle)

    userchoice = input("Enter A, B, C, or D: ")
    if userchoice.upper() == answers[i]:
        print("That's Correct")
        score += riddle_score
    else:
        print("That's Incorrect")

print(f"Here is your score: {score}/{total}!")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文