ceil5 0112. Tip Calculator Complete the function, which calculates how much you need to tip based on the total amount of the bill and the service. You need to consider the following ratings: Terrible: tip 0% Poor: tip 5% Good: tip 10% Great: tip 15% Excellent: tip 20% The rating is case insensitive (so "great" = "GREAT"). If an unrecognised rating is received, then you need to return: "Rating not recognised" in Javascript.. 2023. 1. 13. 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. Round up to the next multiple of 5 Given an integer as input, can you round it to the next (meaning, "higher") multiple of 5? Examples: input: output: 0 -> 0 2 -> 5 3 -> 5 12 -> 15 21 -> 25 30 -> 30 -2 -> 0 -5 -> -5 etc. Input may be any positive or negative integer (including 0). You can assume that all inputs are valid integers. Solution: 1. Divide n by 5 and round up. 2. Multiply the rounded value by 5. def round_to_next5(n): .. 2022. 5. 10. The Office I - Outed Description: Your colleagues have been looking over you shoulder. When you should have been doing your boring real job, you've been using the work computers to smash in endless hours of codewars. In a team meeting, a terrible, awful person declares to the group that you aren't working. You're in trouble. You quickly have to gauge the feeling in the room to decide whether or not you should gather.. 2022. 4. 24. Century From Year Introduction The first century spans from the year 1 up to and including the year 100, the second century - from the year 101 up to and including the year 200, etc. Task Given a year, return the century it is in. Examples 1705 --> 18 1900 --> 19 1601 --> 17 2000 --> 20 Solution: 1. Divide 'year' by 100. 2. Returns the decimal point rounded up. import math def century(year): return math.ceil(year.. 2022. 4. 13. 이전 1 다음