【问题标题】:Python 3.5.2 Calculator issuePython 3.5.2 计算器问题
【发布时间】:2016-11-24 15:37:23
【问题描述】:

这就是我的计算器目前的样子。我这样做是为了学校 python 修订。 http://imgur.com/a/IDJr5

我希望当这个人输入 2 个数字时,它会这样回答 5+5=10

【问题讨论】:

  • 将您的代码粘贴到问题中(不要忘记格式化)。此外,您的代码不会按预期运行,因为所有 or 条件都是错误的。
  • 我的代码确实在我试图做的那个 imgur 中运行
  • 你不应该calculation == "some" or "other"。你应该calculation == "some" or calculation == "other"
  • 甚至calculation in ["some", "other"]
  • 你我现在修好了

标签: python-3.x calculator


【解决方案1】:

你应该改变

print(number1+number2)

到

print("%d + %d = %d" % (number1, number2, number1+number2))

每个操作都以此类推。

【讨论】:

    猜你喜欢
    • 2017-07-28
    • 1970-01-01
    • 2018-07-31
    • 2021-10-18
    • 2020-02-29
    • 2017-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多