110
社区成员
发帖
与我相关
我的任务
分享课程:《Python程序设计》
班级: 2313
姓名: 叶译婷
学号:20231320
实验教师:王志强
实验日期:2024年3月13日
必修/选修: 公选课
1.熟悉Python开发环境;
2.练习Python运行、调试技能;
3.编写程序,练习变量和类型、字符串、对象、缩进和注释等;
4.掌握git技能(可把猜数字游戏上传到gitee)
1.调试pycharm,使其与Gitee连接

2.创建一个仓库,并导入
注意:pycharm中可以直接创建仓库,不需要自己再重新创建

3.将猜数字游戏上传

import random
level=int(input("choose the level:1、2or3,1 is easy,2 is middle,3 is hard:"))
if level==1:
b=random.randint(1,10)
print(" The number is between 1 and 10.")
elif level==2:
b=random.randint(1,100)
print(" The number is between 1 and 100.")
else :
b=random.randint(1,1000)
print(" The number is between 1 and 1000.")
an=int (input("pls a number:"))
c=0
while an>0:
if an==b:
print("you are right,you have guessed",c,"times")
break
elif an<b:
an=int(input("too small,please try again"))
c=c+1
else:
an= int(input("too large,please try again"))
c=c+1
在对程序进行调试的时候,可以多种方法一起使用,将他们结合,再联系实际步骤解决问题。有时也不要完全相信教程,要结合给出的报错提示来进行解决。同时还对Python的语法又一次进行了熟悉。