Round4 1222. Formatting decimal places #0 Each number should be formatted that it is rounded to two decimal places. You don't need to check whether the input is a valid number because only valid numbers are used in the tests. Example: 5.5589 is rounded 5.56 3.3424 is rounded 3.34 Solution: def two_decimal_places(n: float) -> float: l, r = str(n).split(".") r = str(round(int("1"+r[:5]), -3)) return float(".".join([l, r[1:3]])) def two_de.. 2022. 12. 23. 1022. Area of a Square Complete the function that calculates the area of the red square, when the length of the circular arc A is given as the input. Return the result rounded to two decimals. Note: use the π value provided in your language (Math::PI, M_PI, math.pi, etc) Solution: def square_area(A): import math return round((A/math.pi*4/2)**2, 2) 2022. 10. 22. GROCERY STORE: Real Price! You are the owner of the Grocery Store. All your products are in the database, that you have created after CodeWars SQL exercises! :) Customer often need to now how much really they pay for the products. Manufacturers make different sizes of same product so it is hard to compare prices, sometimes they make packages look big, but the weight of the product is small. Make a SELECT query which will .. 2022. 7. 8. Easy SQL: Rounding Decimals Given the following table 'decimals': ** decimals table schema ** id number1 number2 Return a table with two columns (number1, number2), the value in number1 should be rounded down and the value in number2 should be rounded up. Solution: SELECT FLOOR(number1) as number1, CEIL(number2) as number2 FROM decimals Result: number1 number2 2409 -261 1411 -4694 2666 -2280 3616 -2987 4110 -2420 3654 -146.. 2022. 5. 30. 이전 1 다음