Showing posts with label largest numbers. Show all posts
Showing posts with label largest numbers. Show all posts

Monday, June 15, 2015

Program to find two largest numbers using Python

nums = [10, 90, 80, 60, 50]
maxone = 0
maxtwo = 0
for x in nums:
if(maxone < x):
maxtwo = maxone
maxone = x

elif (maxtwo < x):
maxtwo = x

print "First two largest numbers"
print "First largest number:", maxone
print "First largest number:", maxtwo


output:

First two largest numbers
First largest number: 90
First largest number: 80