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