selfteaching / selfteaching/selfteaching-python-camp
Day03 关于”计算器报错“的疑问
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 151
- Forks
- 875
- PR merge metrics
- No merged PRs in 30d
Description
教练,您好:
一、拿到题目后,我琢磨这道题的实现流程应该如下:
1、用户输入”运算字符串(如4+2)";
2、计算机读取该”运算字符串“,而后进行运算;
3、输出结果。
二、落地
1、input可以用来帮我将用户的输入读入计算机;
2、Google让我找到了一个函数“eval“,它可以用来帮我做里面的运算。
3、问题到这里似乎没什么要做的,直接输入结果就可以了。
三、问题
可是我很快意识到:“用户的输入”可能是错的,比如”1/0“,以及其它许多类型的错误。在这样的局面下,计算器程序事实上是无法运行的。
Google让我了解到应该做”exception handling“,可是我写不出正确的“try-except”形式,于是,整个工作陷于“停滞”。
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
The issue concerns the Day03 calculator exercise and mentions Python input, eval, and try-except, but names no repository file or test. Start by locating the Day03 exercise materials and compare the expected calculator behavior with the reported invalid-input cases; the issue does not define a verifiable done condition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100