110
社区成员
发帖
与我相关
我的任务
分享课程:《Python程序设计》
班级: 202322
姓名: 曾键哲
学号:20232208
实验教师:王志强
实验日期:2024年3月13日
必修/选修: 公选课
1.实验内容
1.熟悉 Python 开发环境;
2.练习 Python 运行、调试技能;
3.编写程序,练习变量和类型、字符串、对象、缩进和注释等;
4.掌握 git 技能(可把猜数字游戏上传到 gitee)
2. 实验过程及结果
1.代码如下,运用flag作为标志,决定是否再次进行游戏,用if,elif,else来给予提示
import random
flag = True
while flag:
answer = random.randint(1,200)
user = int(input("Please input your answer!"))
while True:
if user == answer:
print("Right!")
break
elif user > answer:
print("The answer is smaller than the number!")
user = int(input("Please input your answer!"))
else:
print("The answer is bigger than the number!")
user = int(input("Please input your answer!"))
Flag = input("Once again? y/n")
if Flag == 'y':
flag = True
else:
flag = False
2.实验调试时截图

3.将程序托管到gitee


3. 实验过程中遇到的问题和解决过程
- 问题1:pycharm登录gitee账号时跳转浏览器显示404error
- 问题1解决方案:重新绑定邮箱,不用系统自带的邮箱,从第二个选项登陆之后解决
- 问题2:第一次运行时无法退出
- 问题2解决方案:缩进使用错误
其他
第一次写python,有很多和c相似的地方,但是在细微处也有不少不同,有时候容易将两者混用导致编写出错,要更多地实践,熟悉差异
安装了汉化插件,虽然在自己使用时方便了很多,但是在查找资料时,与资料上的图片不容易对应,需要多加适应。
参考资料
- [XXX》](https://book.douban.com/subject/26851579/)
- [XXX](http://www.cnblogs.com/rocedu/p/5182332.html)
- ...