Computer Science
How is math.ceil(89.7) different from math.floor(89.7)?
Python Modules
2 Likes
Answer
The math.ceil(x)
returns the smallest integer greater than or equal to x. In other words, it rounds up to the nearest integer. For 89.7, the smallest integer greater than 89.7 is 90. While math.floor(x)
returns the largest integer less than or equal to x. In other words, it rounds down to the nearest integer. For 89.7, the largest integer less than 89.7 is 89.
Answered By
1 Like
Related Questions
Write a module called calculate_area() that takes base and height as an input argument and returns an area of a triangle as output. The formula used is
Triangle Area = 1⁄2 * base * height
Rewrite the following Python code after removing all syntax error(s). Underline the corrections done.
def main(): r = input('enter any radius:') a = pi * maths.pow(r, 2) Print("Area = "+a) Main()
Out of random() and randint(), which function should we use to generate random numbers between 1 and 5. Justify.
What is the difference between import statement and from import statement?