In this HackerRank Reduce Function problem solution we have Given a list of rational numbers, find their product.

HackerRank Reduce Function in python problem solution

HackerRank Reduce Function in python problem solution

from __future__ import print_function
from fractions import Fraction

def product(fracs):
    t = reduce(lambda x, y: x*y, fracs)
    return t.numerator, t.denominator

if __name__ == '__main__':
    fracs = []
    for _ in range(input()):
        fracs.append(Fraction(*map(int, raw_input().split())))
    result = product(fracs)
    print(*result)