selfteaching / selfteaching/selfteaching-python-camp

Day03 关于编写计算器程序的疑问

Open
#168 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
151
Forks
875
PR merge metrics
No merged PRs in 30d

Description

在今天编写程序的实践中,面对编写加减乘除计算器这个命题,会有多种实现路径:
例如:
方法一:可以定义加法函数,在函数中实现相加运算:
def add(a,b): return a+b print(add(num_1,num_2))

方法二:也可以直接写运算公式实现相加运算。
print(num_1+num_2)

我的问题是:

  1. 这时候要如何做选择?怎么判断哪种方法更好?
  2. 是不是代码行数越少越好,简洁规范的程序标准是什么?

还希望教练、小伙伴们多多指教,谢谢。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading issue #168 and its calculator examples; no repository file or test is identified. Review the existing discussion before drafting guidance on choosing between functions and direct expressions, and consider the work complete when the issue has a clear, agreed answer.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.