mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-07-27 19:57:02 +00:00
ubuiltins.round: Fix example.
The example did not have proper line breaks between statements. Also add an additional example using f-strings.
This commit is contained in:
@@ -1074,8 +1074,9 @@ def round(*args):
|
|||||||
truncate trailing zeros. To print numbers nicely, format strings instead::
|
truncate trailing zeros. To print numbers nicely, format strings instead::
|
||||||
|
|
||||||
# print two decimal places
|
# print two decimal places
|
||||||
print('my number: %.2f' % number) print('my number:
|
print('my number: %.2f' % number)
|
||||||
{:.2f}'.format(number))
|
print('my number: {:.2f}'.format(number))
|
||||||
|
print(f'my number: {number:.2f}')
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
number (float): The number to be rounded.
|
number (float): The number to be rounded.
|
||||||
|
|||||||
Reference in New Issue
Block a user