我无法从这个python程序中的分数中减去一个。当我运行代码时,它显示从0到4的答案,但不是负数,我希望答案为负,如果答案太多是错误的。代码如下:
***print("Hello and welcome to my quiz! ")
score = 0
# this the question i want it to add 1 if answer is correct and subtract 1 if answer is incorrect
print("question 1: what is my name? ")
ans1 = input()
if ans1 == 'mark':
print('correct')
score += 1
else:print('incorrect')
score -= 1
# second question
print("question 2: what is my age? ")
ans2 = input()
if ans2 == '19':
print('correct')
score += 1
else:print('incorrect')
score -= 1
print("question 3: what is my fathers name? ")
ans3 = input()
# third question
if ans3 == 'john':
print('correct')
score += 1
else:print('incorrect')
score -= 1
**# fourth question**
print("question 4: what is my mothers name? ")
ans4 = input()
if ans4 == 'Emily':
print('correct')
score += 1
else:print('incorrect')
score -= 1
print ('your score is', score )
# answer can be in negative***
郎朗坤
摇曳的蔷薇
慕尼黑的夜晚无繁华
相关分类