일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- Python
- iNT
- LOWER
- Sorted
- list
- decorator
- enumerate
- len
- MAX
- count
- map
- WECODE
- 파이썬
- join
- 위코드
- and
- or
- sum
- js
- DART
- Algorithm
- SQL
- FOR
- range
- lambda
- split
- STR
- If
- index
- slice
- Today
- Total
목록and (19)
코드로 우주평화
Create a function that gives a personalized greeting. This function takes two parameters: name and owner. Use conditionals to return the proper message: case name equals owner : 'Hello boss' otherwise : 'Hello guest' Solution: def greet(name: str, owner: str) -> str: return f"Hello {name == owner and 'boss' or 'guest'}"
Wolves have been reintroduced to Great Britain. You are a sheep farmer, and are now plagued by wolves which pretend to be sheep. Fortunately, you are good at spotting them. Warn the sheep in front of the wolf that it is about to be eaten. Remember that you are standing at the front of the queue which is at the end of the array: [sheep, sheep, sheep, sheep, sheep, wolf, sheep, sheep] (YOU ARE HER..
The maximum sum subarray problem consists in finding the maximum sum of a contiguous subsequence in an array or list of integers: max_sequence([-2, 1, -3, 4, -1, 2, 1, -5, 4]) # should be 6: [4, -1, 2, 1] Easy case is when the list is made up of only positive numbers and the maximum sum is the sum of the whole array. If the list is made up of only negative numbers, return 0 instead. Empty list i..
Given two numbers and an arithmetic operator (the name of it, as a string), return the result of the two numbers having that operator used on them. a and b will both be positive integers, and a will always be the first number in the operation, and b always the second. The four operators are "add", "subtract", "divide", "multiply". A few examples:(Input1, Input2, Input3 --> Output) 5, 2, "add" --..
Build Tower Build a pyramid-shaped tower given a positive integer number of floors. A tower block is represented with "*" character. For example, a tower with 3 floors looks like this: [ " * ", " *** ", "*****" ] And a tower with 6 floors looks like this: [ " * ", " *** ", " ***** ", " ******* ", " ********* ", "***********" ] Solution: def tower_builder(n_floors): nums = [i>0 and i*2+1 or 1 for..
Write function bmi that calculates body mass index (bmi = weight / height2). if bmi 25 and "Overweight") \ or (bmi > 18.5 and "Normal") \ or "Underweight"
You are the owner of the Grocery Store. All your products are in the database, that you have created after CodeWars SQL excercises!:) Today you are going to CompanyA warehouse You need to check what products are running out of stock, to know which you need buy in a CompanyA warehouse. Use SELECT to show id, name, stock from products which are only 2 or less item in the stock and are from Company..
Description: We want to generate a function that computes the series starting from 0 and ending until the given number. Example: Input: > 6 Output: 0+1+2+3+4+5+6 = 21 Input: > -15 Output: -15 0 Output: 0=0 Solution: 1. If n is 0, "0=0" is returned. 2. If n is negative, "n
The Western Suburbs Croquet Club has two categories of membership, Senior and Open. They would like your help with an application form that will tell prospective members which category they will be placed. To be a senior, a member must be at least 55 years old and have a handicap greater than 7. In this croquet club, handicaps range from -2 to +26; the better the player the lower the handicap. I..
Create a function which answers the question "Are you playing banjo?". If your name starts with the letter "R" or lower case "r", you are playing banjo! The function takes a name as its only argument, and returns one of the following strings: name + " plays banjo" name + " does not play banjo" Names given are always valid strings. Solution: 1. Check if the first letter of 'name' is 'r'. 2. If it..