본문 바로가기

Python345

1016. Multiplication table for number Your goal is to return multiplication table for number that is always an integer from 1 to 10. For example, a multiplication table (string) for number == 5 looks like below: 1 * 5 = 5 2 * 5 = 10 3 * 5 = 15 4 * 5 = 20 5 * 5 = 25 6 * 5 = 30 7 * 5 = 35 8 * 5 = 40 9 * 5 = 45 10 * 5 = 50 P. S. You can use \n in string to jump to the next line. Note: newlines should be added between rows, but there sh.. 2022. 10. 17.
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.