Monday, April 11, 2011

Python - Min and Max

print "This program takes 10 numbers, and tells you the smallest and the biggest."
print "Now please enter your numbers."

list1 = []
times = 10

while times > 0:
   num = float(raw_input())
   list1.append (num)
   times = times - 1
   del num

which = 0
current = list1[0]

current2 = list1[0]

while which < 9:
  
   if current > list1[which+1]:
      current = list1[which+1]
    
   if current2 < list1[which+1]:
      current2 = list1[which+1]
  
   which = which + 1

print "The smallest is:", current

print "The biggest is:", current2

raw_input()

No comments:

Post a Comment