【Python学习笔记】语法初识

这次试着敲一遍代码之后检查语法错误、

因为之前学过c,所以对标点符号的应用可谓慎之又慎,但还是栽在c的跟前了,习惯性地把所有的print函数敲成了printf函数,如果不是小甲鱼讲还发现不了

对了,还有明白了老程序员都在用的字体consolas

以下是代码:

"""用python设计第一个游戏"""

temp = input("不妨猜一下橙子现在心里想的是哪个数字:")
guess = int(temp)

if guess == 8:
    print("你是橙子心里的蛔虫吗?!")
    print("哼,猜中了也没有奖励!")
else:
    print("猜错啦。橙子现在心里想的是8!")

print("游戏结束,不玩啦>_<")
 

依然保存不了,无法成功运行,看弹幕说因为是3.8.4版本,没办法用中文,所以打算改成英文试试:

3.8.4版本有问题的,目前3个解决办法:
1,用纯英文编写代码
2,不用 IDLE 用比如 PyCharm 等其他编辑器
3,不下载 3.8.4 稳定版 Python , 下载其他版本

果然!!!

"""Design the first game in Python"""

temp = input("Guess which number the orange is thinking:")
guess = int(temp)

if guess == 8:
    print("Are you the worm of the orange?!")
    print("Hum, guess correctly also have no reward!")
else:
    print("Guess wrong.The orange was thinking 8!")

print("Game over. No more playing>_<")
 

程序成功运行!!!

= RESTART: C:/Users/Administrator/AppData/Local/Programs/Python/Python38-32/game.py
Guess which number the orange is thinking:8
Are you the worm of the orange?!
Hum, guess correctly also have no reward!
Game over. No more playing>_<
>>> 
= RESTART: C:/Users/Administrator/AppData/Local/Programs/Python/Python38-32/game.py
Guess which number the orange is thinking:7
Guess wrong.The orange was thinking 8!
Game over. No more playing>_<
>>> 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值