Advertisement
SimeonTs

SUPyF Lists - 03. Smallest Item in List

Jun 15th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. """
  2. Lists
  3. Проверка: https://judge.softuni.bg/Contests/Practice/Index/924#2
  4.  
  5. 03. Smallest Item in List
  6.  
  7. Условие:
  8. Write a program to read a list of integers, find the smallest item and print it.
  9. Examples
  10.  
  11. Input               Output
  12. 1 2 3 4             1
  13. 3 2 9 -9 6 1        -9
  14. -6 0 -17 -1         -17
  15.  
  16. Hints
  17. Loop through the integer list until you find the smallest item
  18. """
  19.  
  20. # We can handle this in a few ways: First - will be as it's asked for in the problem:
  21.  
  22. """
  23. import sys
  24. nums = [int(item) for item in input().split(" ")]
  25.  
  26. min_number = sys.maxsize
  27.  
  28. for item in nums:
  29.    if item < min_number:
  30.        min_number = item
  31.  
  32. print(min_number)
  33. """
  34.  
  35. # but much easier way will be to use the build function in Python for checking the minimum value in list:
  36.  
  37. nums = [int(item) for item in input().split(" ")]
  38. print(min(nums))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement