math11 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. 1026. Beginner Series #4 Cockroach The cockroach is one of the fastest insects. Write a function which takes its speed in km per hour and returns it in cm per second, rounded down to the integer (= floored). For example: 1.08 --> 30 Note! The input is a Real number (actual type is language dependent) and is >= 0. The result should be an Integer. Solution: def cockroach_speed(s): import math return math.floor(km_to_cm(s) / hour_to.. 2022. 10. 26. 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. Factorial In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example: 5! = 5 * 4 * 3 * 2 * 1 = 120. By convention the value of 0! is 1. Write a function to calculate factorial for a given input. If input is below 0 or above 12 throw an exception of type ArgumentOutOfRangeException (C#) or IllegalArgumentException (.. 2022. 8. 7. 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. 이전 1 2 다음