2020-08-13 12:00:20 +02:00
|
|
|
---
|
|
|
|
id: 5e7b9f070b6c005b0e76f05e
|
2021-06-23 21:35:24 +05:30
|
|
|
title: '迭代:循环成语'
|
2020-08-13 12:00:20 +02:00
|
|
|
challengeType: 11
|
|
|
|
videoId: AelGAcoMXbI
|
2021-10-03 12:24:27 -07:00
|
|
|
bilibiliIds:
|
|
|
|
aid: 334491369
|
|
|
|
bvid: BV1tw411R7Mm
|
|
|
|
cid: 376530765
|
2021-01-13 03:31:00 +01:00
|
|
|
dashedName: iterations-loop-idioms
|
2020-08-13 12:00:20 +02:00
|
|
|
---
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --question--
|
|
|
|
|
|
|
|
## --text--
|
|
|
|
|
2021-06-23 21:35:24 +05:30
|
|
|
以下是一个如何在一串数值中找到最小的数值的代码。 一行代码有错误,导致整个代码无法和预期一样的运行。 那么是哪一行?
|
2020-12-16 00:37:30 -07:00
|
|
|
|
|
|
|
```python
|
|
|
|
smallest = None
|
|
|
|
print("Before:", smallest)
|
|
|
|
for itervar in [3, 41, 12, 9, 74, 15]:
|
|
|
|
if smallest is None or itervar < smallest:
|
|
|
|
smallest = itervar
|
|
|
|
break
|
|
|
|
print("Loop:", itervar, smallest)
|
|
|
|
print("Smallest:", smallest)
|
|
|
|
```
|
|
|
|
|
|
|
|
## --answers--
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
## --video-solution--
|
|
|
|
|
|
|
|
3
|
|
|
|
|