鱼C论坛

 找回密码
 立即注册
查看: 55|回复: 1

给点建议

[复制链接]
发表于 2026-8-22 23:41:48 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
my_inch = 74
my_pound = 180
inch_cm = 2.54
pound_kg = 0.4536
inch_to_cm = my_inch * inch_cm
print(f"如果我把{my_inch}和{inch_cm}乘起来,我会得到{inch_to_cm}")
pound_to_kg = my_pound * pound_kg
print(f"如果我把{my_pound}和{pound_kg}乘起来,我会得到{pound_to_kg}")

我这个单位换算对不对,或者给点建议
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2026-8-22 23:41:56 | 显示全部楼层
你的单位换算本身是正确的:
  • 74 英寸 × 2.54 = 187.96 厘米
  • 180 磅 × 0.4536 = 81.648 公斤


但你的代码在输出提示上可以更明确一点,让人一眼看出结果是“长度”或“体重”,而不是单纯“乘起来”。另外建议把换算结果保留两位小数,更实用。

改进版参考:


  1. my_inch = 74
  2. my_pound = 180
  3. inch_cm = 2.54
  4. pound_kg = 0.4536

  5. inch_to_cm = my_inch * inch_cm
  6. pound_to_kg = my_pound * pound_kg

  7. print(f"{my_inch} 英寸 = {inch_to_cm:.2f} 厘米")
  8. print(f"{my_pound} 磅 = {pound_to_kg:.2f} 公斤")
复制代码


修改建议:
  • 把“如果我把……乘起来”改成更直接的等式表达。
  • 使用 .2f 保留两位小数,避免出现过长数字。
  • 变量命名已经很清晰,继续保持。


总体没什么大问题,继续加油!

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-9-18 20:36

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表