1/3 is a periodic tithing; that is, the amount of 3 after the comma is infinite, which makes it impossible to represent it computationally. When you store the value in memory, the value will be truncated according to the architecture you are using, so the fraction representation is no longer 1/3.
Notice that the inconsistency is very explicit even in your example, where it says "1/3 = 0.333". Mathematically, 1/3 is worth 0.33333333333 ..., not just 0.333. They are different numbers, with different generative fractions.
But the main point is: why divide before generating the fraction?
When you read documentation you will see that Fraction
receives two parameters: the numerator and the denominator. That is, just do:
import fractions
a = int(input())
b = fractions.Fraction(1, a)
print(b)
If you enter the value 3, the output will be 1/3.
Notice that the same problem happens in other values, even if they do not generate a periodic tithing. For example, in your code, if you enter the value 5, which should generate the value 0.2, and consequently returning the fraction 1/5 actually returns 3602879701896397/18014398509481984. This is because, similar to what was commented above, the value 1/5 also can not be represented as floating point. The value that looks like 0.2 is actually a value very close to it, which causes the generated fraction to be different than expected.
For more details, read: