1. trunc (): — This function is used to remove the entire decimal part of a floating point number and return an integer without the decimal part.
2 ... ceil (): — This function is used to output the smallest integer greater than a given number .
3. floor (): — This function is used to output the largest integer less than the specified integer .
Output:
The integral value of number is: 3 The smallest integer greater than number is: 4 The greatest integer smaller than number is: 3
Setting Accuracy
There are many ways to set the correct a number of floating point values. Some of these are discussed below.
1. Using "%" : — the "%" operator is used for formatting as well as setting precision in python. This is similar to the "printf" statement in C .
2. Using format (): — is another way to format a string to set precision.
3. Using round (x, n): — This function takes 2 arguments, a number and the number to which we want to round the decimal part.


Output:
The value of number till 2 decimal place (using%) is: 3.45 The value of number till 2 decimal place (using format ()) is: 3.45 The value of number till 2 decimal place (using round ()) is: 3.45
This article courtesy of Manjeet Singh . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you would like to share more information on the topic discussed above.