Python345 0905. Training JS #7: if..else and ternary operator In JavaScript, if..else is the most basic condition statement, it consists of three parts:condition, statement1, statement2, like this: if condition: statementa else: statementb It means that if the condition is true, then execute the statementa, otherwise execute the statementb.If the statementa or statementb more than one line, you need to add { and } at the head and tail of statement in JS, t.. 2022. 9. 5. 0904. No zeros for heros Numbers ending with zeros are boring. They might be fun in your world, but not here. Get rid of them. Only the ending ones. 1450 -> 145 960000 -> 96 1050 -> 105 -1050 -> -105Zero alone is fine, don't worry about it. Poor guy anyway Solution: def remove_zero(func): def wrapper(n: int): s = str(n).rstrip("0") return func(s) return wrapper @remove_zero def no_boring_zeros(s: str): return s and .. 2022. 9. 4. 0903. L1: Bartender, drinks! Complete the function that receives as input a string, and produces outputs according to the following table: Input Output "Jabroni" "Patron Tequila" "School Counselor" "Anything with Alcohol" "Programmer" "Hipster Craft Beer" "Bike Gang Member" "Moonshine" "Politician" "Your tax dollars" "Rapper" "Cristal" anything else "Beer" Note: anything else is the default case: if the input to the functio.. 2022. 9. 3. 0902. Simple multiplication This kata is about multiplying a given number by eight if it is an even number and by nine otherwise. Solution: def multiply_factor(func): def wrapper(n): return func(n, n%2 and 9 or 8) return wrapper @multiply_factor def simple_multiplication(n: int, m: int) -> int: return n*m 2022. 9. 2. 0901. Alan Partridge II - Apple Turnover Backstory As a treat, I'll let you read part of the script from a classic 'I'm Alan Partridge episode: Lynn: Alan, there’s that teacher chap. Alan: Michael, if he hits me, will you hit him first? Michael: No, he’s a customer. I cannot hit customers. I’ve been told. I’ll go and get some stock. Alan: Yeah, chicken stock. Phil: Hello Alan. Alan: Lynn, hand me an apple pie. And remove yourself from .. 2022. 9. 1. 0831. Correct the mistakes of the character recognition software Character recognition software is widely used to digitise printed texts. Thus the texts can be edited, searched and stored on a computer. When documents (especially pretty old ones written with a typewriter), are digitised character recognition softwares often make mistakes. Your task is correct the errors in the digitised text. You only have to handle the following mistakes: S is misinterpreted.. 2022. 8. 31. 이전 1 ··· 23 24 25 26 27 28 29 ··· 58 다음