学号 2024-2025-2 《Python程序设计》实验x报告
课程:《Python程序设计》
班级: XXXX
姓名: XXX
学号:XXX
实验教师:XXX
实验日期:2025年3月12日
必修/选修: 公选课
1.实验内容
1.熟悉Python开发环境;
2.练习Python运行、调试技能;(编写书中的程序,并进行调试分析,要有过程)
3.编写程序,练习变量和类型、字符串、对象、缩进和注释等;(编写一个猜数字或者剪刀石头布的游戏)
4. 掌握git技能
2. 实验过程及结果
1.实验代码
import random
guess = 1<<5000
print("""
⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
welcome !!!!
⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
pip install pyinstallerpyinstaller test.py
""")
while True:
level = int(input("please input the level:(from 1 to 3)"))
if level == 1:target = random.randint(1,10)
elif level == 2:target = random.randint(1,20)
else:target = random.randint(1, 30)while guess!=target:guess = int(input("input your num:")) #input 是strif guess == target:print("right!!!")else:if guess > target:print("what a pity!")print("your num is too big")else:print("what a pity!")print("your num is too small")ss = input("would you like to try again?")
if ss == "yes":continue
else:break
2.实验步骤操作
pip install pyinstaller
pyinstaller test.py
ls
cd dist
cd test
./test.exe
3. 实验过程中遇到的问题和解决过程
- 问题1:./test没有反应
- 问题1解决方案:应该执行.exe文件