We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2c06916 commit 32b78c4Copy full SHA for 32b78c4
PythonFunctionals/ReduceFunction.py
@@ -0,0 +1,25 @@
1
+'''
2
+Title : Reduce Function
3
+Subdomain : Python Functionals
4
+Domain : Python
5
+Author : Ahmedur Rahman Shovon
6
+Created : 24 January 2017
7
8
+from fractions import Fraction
9
+from functools import reduce
10
+def product(fracs):
11
+ t = Fraction(reduce(lambda x,y : x*y,fracs))
12
+ return t.numerator, t.denominator
13
+if __name__ == '__main__':
14
+ fracs = []
15
+ for _ in range(int(input())):
16
+ fracs.append(Fraction(*map(int, input().split())))
17
+ result = product(fracs)
18
+ print(*result)
19
+
20
21
+3
22
+1 2
23
+3 4
24
+10 6
25
0 commit comments