马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
Python 3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
temp=input("你是谁")
你是谁
temp=input("你是谁:")
你是谁:我是你霸霸
print(temp)
我是你霸霸
int(temp)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
int(temp)
ValueError: invalid literal for int() with base 10: '我是你霸霸'
temp=input("请输入一个数字:")
请输入一个数字:8
print(temp)
8
guess=int(temp)
print(guess)
8
3<4
True
5<3
False
3<=3
True
5<=3
False
5< =3
SyntaxError: invalid syntax
3==3
True
1==2
False
3!=3
False
1!=2
True
以上是在交互模式下完成的,IDLE Shell3.12.1
以下是在编辑模式下完成的,在交互模式下,点击右上角的“file”,选择”New File“,有”run“菜单的,看看if的运用。
"""用Python设计的第一个游戏""
temp=input("不妨猜一下,小甲鱼心里现在想的是什么数字:")
guess=int(temp)
if guess==8:
print("你是小甲鱼心里的蛔虫吗?!")
print("哼,猜中了也没有奖励!")
else:
print("猜错了,小甲鱼现在心里想的是8!")
print("游戏结束,不玩啦^_^")
|