f | from fractions import Fraction | f | from fractions import Fraction |
| s = input().replace(' ', '') | | s = input().replace(' ', '') |
n | oper = ['(', ')', '+', '-', '*', '/', '%'] | n | simb = ['(', ')', '+', '-', '*', '/', '%'] |
| ans = '' | | res = '' |
| digit = False | | fl = False |
| for i in range(len(s)): | | for i in range(len(s)): |
n | if s[i] in oper: | n | if s[i] in simb: |
| if digit: | | if fl: |
| ans += f"Fraction('{s[start:i]}')" | | res += f"Fraction('{s[start:i]}')" |
| digit = False | | fl = False |
| ans += s[i] | | res += s[i] |
| elif not digit: | | elif not fl: |
| digit = True | | fl = True |
| start = i | | start = i |
t | if digit: | t | if fl: |
| ans += f"Fraction('{s[start:]}')" | | res += f"Fraction('{s[start:]}')" |
| print(eval(ans)) | | print(eval(res)) |