Imprimez deux chiffres après décimal Python
float = 2.154327
format_float = "{:.2f}".format(float)
print(format_float)
Sore Stork
float = 2.154327
format_float = "{:.2f}".format(float)
print(format_float)
a = 1.2138568
print(f'{a:.2f}')
#to round floats in Python you can use the "round" function. ex:
tax = 34.4563
tax = round(tax, 2)
#the number 2 at the end is how many digits are rounded.
#the variable "tax" would now be: 34.46
# round a value to 2 decimal points
value_to_print = 123.456
print(f'value is {round(value_to_print, 2)}')
# prints: value is 123.46
# this will print up to digits after decimal
print("%.2f" % (70/105))
print("{0:.2f}".format(sum(query_marks)/len(query_marks)))