How to print a floating number upto 2 decimal places with a sign in Python

1 Answer

0 votes
x = 3.141592
y = -5.99999

print("{:+.2f}".format(x));

print("{:+.2f}".format(y));




'''
run:

+3.14
-6.00

'''

 



answered Sep 2, 2021 by avibootz

Related questions

...