I am trying to limit my decimal places to 2 while printing the value of Pi.
Below is my expression after installing the match module in Anaconda Notebook
x=math.pi
print(float(x) (%2f))
Could you help fix the code/expression to print 3.14
I am trying to limit my decimal places to 2 while printing the value of Pi.
Below is my expression after installing the match module in Anaconda Notebook
x=math.pi
print(float(x) (%2f))
Could you help fix the code/expression to print 3.14
 
    
    You are looking for
x = math.pi
print(f"{x:.2f}")
This is called an f-string. It formats x as a string of a  floating point number (f) with 2 decimal places (.2f).
