selfteaching / selfteaching/selfteaching-python-camp
Day03 关于编写计算器程序的疑问
Open
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)
我的问题是:
- 这时候要如何做选择?怎么判断哪种方法更好?
- 是不是代码行数越少越好,简洁规范的程序标准是什么?
还希望教练、小伙伴们多多指教,谢谢。
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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