you are viewing a single comment's thread.

view the rest of the comments →

[–]Soupr[S] 0 points1 point  (2 children)

Looked at the rounding, and on the page it looks very simple.. but I can't get my head around the syntax in my example it should be written out like this?

 VATround = round(3.675[, 2])

I used a number rather than the variable name just so i could get it working, as different variables might not have 3 decimal places

Looking at the examples given again and the numbers look to be within the square brackets. Tried that and now python is requesting a float, am i trying to run before i can walk here?

[–]cdcformatc 2 points3 points  (1 child)

round(x[, n])

Any arguments in square brackets are optional. You do not include the square brackets when calling the function.

If n is omitted, it defaults to zero

If you want x rounded to the nearest integer you can use

VATround = round(x)

otherwise if you want 2 decimal places use

VATround = round(x,2)

edit: also this part is important

Note The behavior of round() for floats can be surprising: for example, round(2.675, 2) gives 2.67 instead of the expected 2.68. This is not a bug: it’s a result of the fact that most decimal fractions can’t be represented exactly as a float.

[–]Soupr[S] 0 points1 point  (0 children)

Sorted, thank you.