Q. Write a program to read two lists num and denum which contain the numerators and denominators of same fractions at the respective indexes. Then display the smallest fraction along with its index.

Answer =

num = eval(input("Enter numerators list :-"))
denum = eval(input("Enter denominators list :-"))
lst = [ ]
for i in range(len(num)) :
      fraction = num[ i ] / denum[ i ]
      lst.append( fraction )

lst.sort()
print("Smallest fraction = ",lst[ 0 ])

Output : - 

Enter numerators list :-[0,2,4,6,8]
Enter denominators list :-[1,3,5,7,9]
Smallest fraction =  0.0

>>> 

Enter numerators list :-[98,45,23,47]
Enter denumerators list :-[54,26,89,74]
Smallest fraction =  0.25842696629213485

>>> 


9 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post