使用空闲 Python 3.4.3。这是一个脚本,它给用户一个小测验,然后计算有多少是正确的。在我的脚本运行之前,我在评论中遇到了无效的语法错误。这是评论周围的整个代码。具体评论在下面一行score = decimal.Decimal(score):
score = amountright/7*100 """this takes the amount of questions the user got right, divides it by 7 (the total number of questions), then multiplies it by 100 to get a percentage correct and stores it in the variable score"""
import decimal """this will import a function to round off the final percentage to a whole number instead of an unnecessarily long decimal"""
score = decimal.Decimal(score)
"""this redefines the score variable as some sort …Run Code Online (Sandbox Code Playgroud)