Find a Nth highest or lowest numbers in a given series of integers using indexing technique in Python

Rajnilari2015
Posted by Rajnilari2015 under Python category on | Points: 40 | Views : 215
from System import *
from System.Collections.Generic import *
from System.Linq import *

class Program(object):
def Main(args):
#Question #3: Find a Nth highest or lowest number in a given series of numbers.
lstNumbers = List[Double](1, 2.06, -36.4, -4, 5.90, 618.9, 79.8, 8, 9, 18.0, 23.7)
itemsCount = lstNumbers.Count
sortedList = lstNumbers.OrderBy().ToList()
minNum = sortedList[0]
maxNum = sortedList[itemsCount - 1]
Console.WriteLine("Min = {0} , Max = {1}", minNum, maxNum)

Main = staticmethod(Main)

Comments or Responses

Login to post response