pythonV1V2/第9讲亲开会员吗/课堂成果/课后作业_击败boss凶抓龙.py
sairate 7df250638d chore: 添加项目基础结构和示例代码
- 创建 .idea 目录和相关配置文件,设置项目结构
- 添加多个课堂成果示例代码,涵盖不同主题和功能
- 创建和配置 .gitignore 文件,忽略特定文件和目录
2025-07-05 09:36:00 +08:00

14 lines
1003 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#请在这里编写代码
print("欢迎来到怪物的老巢。")
print("请打败boss凶爪龙拯救无辜村民。") # 故事介绍
boss_hp = 10 # 将boss的hp值预设为10
print(f"boss凶爪龙的hp值为{str(boss_hp)},准备开始战斗!") # 作战开始的提示
for i in range(10): # 循环10次请求攻击
attack = int(input("请输入数字1攻击boss凶爪龙")) # 在attack进攻变量中记录输入的内容
if attack == 1: # 如果输入的数据为1
boss_hp = boss_hp - 1 # boss掉血1点
print(f"boss凶爪龙的血量还剩{str(boss_hp)},继续加油啊!") # 输出boss剩余血量
if boss_hp == 0: # 如果boss的hp值为0说明boss被击败
print("大英雄恭喜你击败boss凶爪龙") # 输出游戏胜利提示
else: # 如果攻击时输入的数据不是1
print("请输入数字1进攻") # 则会提示“请输入数字1进攻