전체 글823 Adults only (SQL for Beginners #1) In your application, there is a section for adults only. You need to get a list of names and ages of users from the users table, who are 18 years old or older. users table schema name age NOTE: Your solution should use pure SQL. Ruby is used within the test cases just to validate your answer. Solution: SELECT name, age FROM users WHERE age >= 18 2022. 6. 25. SQL: Padding Encryption You are given a table with the following format: ** encryption table schema ** md5 sha1 sha256 Problem is the table looks so unbalanced - the sha256 column contains much longer strings. You need to balance things up. Add '1' to the end of the md5 addresses as many times as you need to to make them the same length as those in the sha256 column. Add '0' to the beginning of the sha1 values to achie.. 2022. 6. 23. Sum of angles Find the total sum of internal angles (in degrees) in an n-sided simple polygon. N will be greater than 2. Solution: SELECT 180 * (n - 2) AS res FROM angle The sum of the interior angles of an n-gon is 180˚× (n-2). Result: res 9720 12960 10080 15660 12780 5400 16920 2022. 6. 22. Python _ TypedDict를 사용하는 이유(feat. mypy) Python도 Type을 확인한다구! 파이썬은 타입 힌트를 제공함으로써 해당 데이터가 어떤 타입을 갖고 있는지 알 수 있다. 다만 파이썬은 타입을 강제하지 않기 때문에 일반 런타임 환경에서는 타입의 정상여부를 알기 어렵다. 때문에 타입이 정상인지 확인하기 위해 mypy 나 pyright 같은 정적 검사 도구를 이용한다. 하지만 그럼에도 애매한 경우가 있는데 바로 dict와 같은 value들이 다양한 타입을 가질 경우이다. dict value들의 타입을 일일이 확인하고 명시하기란 매우 귀찮은 일이다. 때문에 Dict[str, Any] 처럼 value에 해당되는 타입을 Any로 넘기는 경우가 많다. 하지만 이는 바람직하지 않다. Any가 어떤 문제를 일으키는지 먼저 살펴보고, 이에 대한 해결책으로서 Type.. 2022. 6. 22. SQL Basics: Up and Down Given a table of random numbers as follows: numbers table schema id number1 number2 Your job is to return table with similar structure and headings, where if the sum of a column is odd, the column shows the minimum value for that column, and when the sum is even, it shows the max value. You must use a case statement. output table schema number1 number2 Solution: SELECT CASE WHEN MOD(SUM(number1).. 2022. 6. 21. Python _ dict의 keys()처럼 dataclass에서 속성 목록 가져오기 파이썬에서 객체를 만드는 방법 중에 dataclass가 있다. @dataclass 데코레이터를 사용하면 타입 유형을 명시한 객체를 만들 수 있다. dataclass를 만드는 코드는 아래와 같다. from dataclasses import dataclass @dataclass(frozen=True) class Dataclass: a:int b:int c:int data = Dataclass(a=1,b=3,c=5) print(data) # 출력 : Dataclass(a=1, b=3, c=5) print(data.a) # 1 print(data.b) # 3 print(data.c) # 5 이렇게 만든 객체는 타입 유형을 명시하고 싶을 때나 DTO, 값 객체 등의 불변 객체로도 사용할 수 있다. dataclas.. 2022. 6. 21. 이전 1 ··· 71 72 73 74 75 76 77 ··· 138 다음