나는 이렇게 학습한다575 1015. simple calculator You are required to create a simple calculator that returns the result of addition, subtraction, multiplication or division of two numbers. Your function will accept three arguments: The first and second argument should be numbers. The third argument should represent a sign indicating the operation to perform on these two numbers. if the variables are not numbers or the sign does not belong to t.. 2022. 10. 15. 1014. Find Multiples of a Number In this simple exercise, you will build a program that takes a value, integer , and returns a list of its multiples up to another value, limit . If limit is a multiple of integer, it should be included as well. There will only ever be positive integers passed into the function, not consisting of 0. The limit will always be higher than the base. For example, if the parameters passed are (2, 6), t.. 2022. 10. 14. 1013. Area or Perimeter You are given the length and width of a 4-sided polygon. The polygon can either be a rectangle or a square. If it is a square, return its area. If it is a rectangle, return its perimeter. Example(Input1, Input2 --> Output): 6, 10 --> 32 3, 3 --> 9 Note: for the purposes of this kata you will assume that it is a square if its length and width are equal, otherwise it is a rectangle. Solution: def .. 2022. 10. 13. 1012. All Star Code Challenge #18 This Kata is intended as a small challenge for my students All Star Code Challenge #18 Create a function that accepts 2 string arguments and returns an integer of the count of occurrences the 2nd argument is found in the first one. If no occurrences can be found, a count of 0 should be returned. ("Hello", "o") ==> 1 ("Hello", "l") ==> 2 ("", "z") ==> 0 Notes: The first argument can be an empty s.. 2022. 10. 12. 1011. Square(n) Sum Complete the square sum function so that it squares each number passed into it and then sums the results together. For example, for [1, 2, 2] it should return 9 because 1^2 + 2^2 + 2^2 = 9. Solution: def square_sum(numbers): square = lambda x:(x**2+x**2)//2 return sum(square(number) for number in numbers) 2022. 10. 11. 1010. Double Char Given a string, you have to return a string in which each character (case-sensitive) is repeated once. Examples (Input -> Output): * "String" -> "SSttrriinngg" * "Hello World" -> "HHeelllloo WWoorrlldd" * "1234!_ " -> "11223344!!__ " Good Luck! Solution: def double_char(s: str) -> str: return "".join((lambda x: x+x)(i) for i in s) 2022. 10. 10. 이전 1 ··· 26 27 28 29 30 31 32 ··· 96 다음