Floor5 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. Keep Hydrated! Nathan loves cycling. Because Nathan knows it is important to stay hydrated, he drinks 0.5 litres of water per hour of cycling. You get given the time in hours and you need to return the number of litres Nathan will drink, rounded to the smallest value. For example: hours = 3 ----> liters = 1 hours = 6.7---> liters = 3 hours = 11.8--> liters = 5 You have to return 3 columns: id, hours and liters.. 2022. 6. 12. 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. Get the mean of an array Description: It's the academic year's end, fateful moment of your school report. The averages must be calculated. All the students come to you and entreat you to calculate their average for them. Easy ! You just need to write a script. Return the average of the given array rounded down to its nearest integer. The array will never be empty. Solution: 1. Find the average. 2. Rounds down to an inte.. 2022. 4. 15. Growth of a Population Description: In a small town the population is p0 = 1000 at the beginning of a year. The population regularly increases by 2 percent per year and moreover 50 new inhabitants per year come to live in the town. How many years does the town need to see its population greater or equal to p = 1200 inhabitants? At the end of the first year there will be: 1000 + 1000 * 0.02 + 50 => 1070 inhabitants At .. 2022. 3. 1. 이전 1 다음