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