일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- index
- range
- SQL
- 위코드
- or
- 파이썬
- join
- slice
- count
- list
- decorator
- iNT
- Python
- sum
- map
- LOWER
- split
- enumerate
- len
- lambda
- WECODE
- and
- STR
- DART
- js
- Algorithm
- Sorted
- FOR
- If
- MAX
- Today
- Total
목록iNT (18)
코드로 우주평화
Filter the number Oh, no! The number has been mixed up with the text. Your goal is to retrieve the number from the text, can you return the number back to its original state? Task Your task is to return a number from a string. Details You will be given a string of numbers and letters mixed up, you have to return all the numbers in that string in the order they occur. Solution: def filter_string(..
Consider an array/list of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep present in the array (true means present). For example, [True, True, True, False, True, True, True, True , True, False, True, False, True, False, False, True , True, True, True, True , False, False, True, True] The correct answer would be 17. Hint: Don't forget to ..
Write a function that will check if two given characters are the same case. If either of the characters is not a letter, return -1 If both characters are the same case, return 1 If both characters are letters, but not the same case, return 0 Examples 'a' and 'g' returns 1 'A' and 'C' returns 1 'b' and 'G' returns 0 'B' and 'g' returns 0 '0' and '?' returns -1 Solution: def same_case(a: str, b: s..
Basic regex tasks. Write a function that takes in a numeric code of any length. The function should check if the code begins with 1, 2, or 3 and return true if so. Return false otherwise. You can assume the input will always be a number. Solution: def validate_code(code: int) -> bool: return int(str(code)[0])
Each number should be formatted that it is rounded to two decimal places. You don't need to check whether the input is a valid number because only valid numbers are used in the tests. Example: 5.5589 is rounded 5.56 3.3424 is rounded 3.34 Solution: def two_decimal_places(n: float) -> float: l, r = str(n).split(".") r = str(round(int("1"+r[:5]), -3)) return float(".".join([l, r[1:3]])) def two_de..
You ask a small girl,"How old are you?" She always says, "x years old", where x is a random number between 0 and 9. Write a program that returns the girl's age (0-9) as an integer. Assume the test input string is always a valid string. For example, the test input may be "1 year old" or "5 years old". The first character in the string is always a number. Solution: def get_age(age): def get_int(ag..
Given an array of integers as strings and numbers, return the sum of the array values as if all were numbers. Return your answer as a number. sum_mix = lambda x: sum(map(int, x))
Create a function that takes 2 integers in form of a string as an input, and outputs the sum (also as a string): Example: (Input1, Input2 -->Output) "4", "5" --> "9" "34", "5" --> "39" "", "" --> "0" "2", "" --> "2" "-5", "3" --> "-2" Notes: If either input is an empty string, consider it as zero. Inputs and the expected output will never exceed the signed 32-bit integer limit (2^31 - 1) Solutio..
Given a string of digits, you should replace any digit below 5 with '0' and any digit 5 and above with '1'. Return the resulting string. Note: input will never be an empty string Solution: def fake_bin(x): return ''.join(str(int(i) >= 5 and 1 or 0) for i in x)
Write a function that always returns 5 Sounds easy right? Just bear in mind that you can't use any of the following characters: 0123456789*+-/ Good luck :) Solution: def unusual_five(): return int([i for i in str(ord("A"))].pop()) Other Solution: def unusual_five(): return len("five!") def unusual_five(): return ord("")