ChamplainTechJournals/python-csi160/week05/week-5Practice-Problems/part7.py
2025-04-19 23:42:08 -04:00

15 lines
472 B
Python

def second_smallest(numbers):
"""Returns the second smallest number
:param numbers: (list) List of numbers of at least size 2
:return: (int or float) The second smallest number
"""
numbers.sort()
return numbers[1]
# Leave this part for easily testing your function
print('[6, 3, 9, 2, 1] second_smallest returns', second_smallest([6, 3, 9, 2, 1]))
print('[23, 23.25, 23.5, 23] second_smallest returns', second_smallest([23, 23.25, 23.5, 23]))