鱼C论坛

 找回密码
 立即注册
查看: 3418|回复: 10

[已解决]求各位大佬指点一下【Python】

[复制链接]
发表于 2021-9-25 12:28:31 | 显示全部楼层
程序1:“无赖”的方法。
  1. import operator
  2. n1 = int(input())
  3. n2 = int(input())
  4. result = operator.mul(n1, n2)
  5. print(f'{n1} X {n2} = {result}')
复制代码

程序1 正式的方法
  1. n1 = int(input())
  2. n2 = int(input())
  3. result = 0
  4. if n1 and n2:
  5.     n3 = abs(n2)
  6.     for i in range(n3):
  7.         result += n1
  8.     result = result if n2 == n3 else -result
  9. print(f'{n1} X {n2} = {result}')
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-5 04:21

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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