py实验一

2、九九乘法表。

编写程序,输出九九乘法表。

源代码:

for a in range(1, 10):

for b in range(1, a+1):

print(f"{a}*{b}={a * b}", end=" ")

print()

列出测试数据和实验结果截图:

3、编写程序,解决"百钱百鸡"问题。

一只公鸡值五钱,一只母鸡值三钱,三只小鸡值一钱。

源代码:

for a in range(1, 101):

for b in range(1, 101):

for c in range(1, 101):

if (a * 5 + b * 3 + c / 3 == 100) & (a + b + c == 100):

print(f"公鸡{a}只,母鸡{b}只,小鸡{c}只")

列出测试数据和实验结果截图:

相关推荐
用户8358086187911 小时前
基于 Self-RAG 与列表级重排序的进阶 RAG 系统设计与实现
python
Warson_L17 小时前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅17 小时前
海天线算法的前世今生
python·计算机视觉
韩师傅18 小时前
当你的甲方设备过烂,要如何快速出效果?
python·计算机视觉
Warson_L18 小时前
LangGraph的MessageState and HumanMessage
python
韩师傅18 小时前
当你的甲方吐槽天空不够蓝,你应该如何应对
python·计算机视觉
Warson_L19 小时前
python的类&继承
python
Warson_L19 小时前
类型标注/type annotation
python
ThreeS21 小时前
手搓MiniVLA全实战教程-一步一步用pytorch解释原理与思路
人工智能·python
金銀銅鐵1 天前
[Python] 模 n 乘法的逆元计算器
python·数学·游戏