|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
print("Hello,welcome to play this game")
name = input("Now,please tell me you name:")
print("Welcome back"+ name +"!")
print("Now,i want to ask you some question")
num = input("The first question is 9+8=:")
if num == 17:
print("Good,It's right")
else:
print("No,It's wrong")
num2 = input("Now,the second question is 9-2=:")
if num2 == 7:
print("Good,It's right")
else:
print("No,It's wrong")
num3 =input("Now,the third question is 6*6")
if num3 == 36:
print("Good,It's right")
else:
print("No,It's wrong")
num4 = input("The last questian is 6/3")
if num4 == 2:
print("Good,It's right")
else:
print("No,It's wrong")
print("Thanks for your play")
print("I wish you will like whis game ")
print("I hope you can come to play the game made by me again")
print("Bye bye")
上面这串代码运行后就是输入的是正确答案回答也是wrong,请问哪里有问题,该怎么修改?
(初学者,看过第三集小甲鱼的Python视频后就想着自己也做一个,还有很多东西我都不懂,也请各位大神多包涵)
input的默认返回值是字符串,要将字符串转换成int类型
- print("Hello,welcome to play this game")
- name = input("Now,please tell me you name:")
- print("Welcome back"+ name +"!")
- print("Now,i want to ask you some question")
- num = int(input("The first question is 9+8=:"))
- if num == 17:
- print("Good,It's right")
- else:
- print("No,It's wrong")
- num2 = input("Now,the second question is 9-2=:")
- if num2 == 7:
- print("Good,It's right")
- else:
- print("No,It's wrong")
- num3 =input("Now,the third question is 6*6")
- if num3 == 36:
- print("Good,It's right")
- else:
- print("No,It's wrong")
- num4 = input("The last questian is 6/3")
- if num4 == 2:
- print("Good,It's right")
- else:
- print("No,It's wrong")
- print("Thanks for your play")
- print("I wish you will like whis game ")
- print("I hope you can come to play the game made by me again")
- print("Bye bye")
复制代码
|
|