python四则运算例题
时间: 2023-09-26 19:14:27 浏览: 142
以下是一个Python的四则运算例题:
```python
opr = ['+', '-', '×', '÷']
fh = random.randint(0, 4)
if fh == 0:
rjg = newfra()
jg = input()
if jg == '0000':
break;
sr = Fraction(jg)
if sr == rjg:
print('right')
else:
print('error. the Tight answer is', rjg)
else:
rjg = newint()
jg = input()
if jg == '0000':
break;
sr = int(jg)
if sr == rjg:
print('right')
else:
print('error. the Tight answer is', rjg)
```
这个例题是在Python中进行四则运算的一个示例。程序会随机选择加法、减法、乘法或除法,并生成相应的题目。用户需要输入答案,如果答案正确,则输出"right",否则输出"error"。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [python的四则运算练习](https://blog.csdn.net/weixin_42350314/article/details/114455029)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [Python函数综合案例.md](https://download.csdn.net/download/qq_42431718/88241199)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文