...

Chapter 14 - Python Quest

Algorithm Workshop

Trace state, swap safely, and compare selection sort with bubble sort.

XP
0Level 1
Stars
0/18quest stars
Combo
0clean runs
Rank
Seed0/160 Python score
Running-best algorithms

Smallest Number Scout

100 XP

A mountain rescue team compares beacon heights and needs one scout to remember the lowest reading seen during a single walk through the list.

Write smallest_number(numbers) so it returns the smallest value in the nonempty list. Build the scan yourself without using min, sorted, or list.sort.

Sample checks

smallest_number([7,3,9,1,5])returns1

Explanation: the remembered smallest value changes from 7 to 3 when 3 is seen, stays 3 at 9, changes to 1, and remains 1 after 5

smallest_number([4])returns4

Explanation: the only value 4 becomes the starting champion, and because there are no later values to challenge it, 4 is returned

Hint

Hints are ready when you want one.

Lesson reference

Review: Carry a running best value

Your Python

smallest_number

Loading editor

Judge

Ready

0/4

Run your code when it feels ready.