Home>

Nice to get started with python3 and jupyter notebook recently.
The output does not change even when a command (% precision x: x is an arbitrary digit) that specifies the number of digits to display in jupyter notebook is used.

#Display up to 3 decimal places
% precision 3

Output

'%. 3f

Execution result (covariance calculation)

6.906000000000002

Just,
Outputs such as 1/3 and 11/3 are firmly displayed in three digits.

Input

1/3

Output

0.333

Why is it? Thanks for your response.

  • Answer # 1

    How did you display the results?

    1/3


    Will give0.333, but

    print (1/3)

    You should get0.3333333333333333.

    The former gives the valueJupyterevaluates, while the latter shows the dataPythonwrites to standard output.
    Is that the difference?

Related articles