본문 바로가기

If41

0108. How many lightsabers do you own? Inspired by the development team at Vooza, write the function that accepts the name of a programmer, and returns the number of lightsabers owned by that person. The only person who owns lightsabers is Zach, by the way. He owns 18, which is an awesome number of lightsabers. Anyone else owns 0. Note: your function should have a default parameter. For example(Input --> Output): "anyone else" --> 0 .. 2023. 1. 9.
0101. Pillars There are pillars near the road. The distance between the pillars is the same and the width of the pillars is the same. Your function accepts three arguments: number of pillars (≥ 1); distance between pillars (10 - 30 meters); width of the pillar (10 - 50 centimeters). Calculate the distance between the first and the last pillar in centimeters (without the width of the first and last pillar). So.. 2023. 1. 1.
1220. The 'if' function Create a function called _if which takes 3 arguments: a boolean value bool and 2 functions (which do not take any parameters): func1 and func2 When bool is truth-ish, func1 should be called, otherwise call the func2. Example: def truthy(): print("True") def falsey(): print("False") _if(True, truthy, falsey) # prints 'True' to the console Solution: def _if(bool, func1, func2): return func1() if b.. 2022. 12. 20.
1201. Is the string uppercase? Is the string uppercase? Task Create a method to see whether the string is ALL CAPS. Examples (input -> output) "c" -> False "C" -> True "hello I AM DONALD" -> False "HELLO I AM DONALD" -> True "ACSKLDFJSgSKLDFJSKLDFJ" -> False "ACSKLDFJSGSKLDFJSKLDFJ" -> True In this Kata, a string is said to be in ALL CAPS whenever it does not contain any lowercase letter so any string containing no letters at.. 2022. 12. 1.
1121. Grasshopper - Grade book Grade book Complete the function so that it finds the average of the three scores passed to it and returns the letter value associated with that grade. Numerical Score Letter Grade 90 2022. 11. 22.
1119. Return Negative In this simple assignment you are given a number and have to make it negative. But maybe the number is already negative? Examples makeNegative(1); // return -1 makeNegative(-5); // return -5 makeNegative(0); // return 0 makeNegative(0.12); // return -0.12 Notes The number can be negative already, in which case no change is required. Zero (0) is not checked for any specific sign. Negative zeros m.. 2022. 11. 19.