전체 글 (306)
2022-04-19 15:18:11
반응형

0차원 배열 

 

 

 스칼라 array 함수

 

'''
   배열생성
   0차원 배열:  스칼라
'''
import numpy as np
print("numpy 버전:", np.__version__) # numpy 버전: 1.22.3

# 1. 스칼라 생성
s = np.array(10)

print("값:", s) # 10
print("타입:", type(s)) # <class 'numpy.ndarray'>
print("차원:", s.ndim) # 0
print("형상(모양):", s.shape) # ()

print(dir(np))
'''
['ALLOW_THREADS', 'AxisError', 'BUFSIZE', 'CLIP', 'ComplexWarning', 'DataSource', 
'ERR_CALL', 'ERR_DEFAULT', 'ERR_IGNORE', 'ERR_LOG', 'ERR_PRINT', 'ERR_RAISE', 
'ERR_WARN', 'FLOATING_POINT_SUPPORT', 'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 
'FPE_UNDERFLOW', 'False_', 'Inf', 'Infinity', 'MAXDIMS', 'MAY_SHARE_BOUNDS', 'MAY_SHARE_EXACT', 
'ModuleDeprecationWarning', 'NAN', 'NINF', 'NZERO', 'NaN', 'PINF', 'PZERO', 'RAISE', 'RankWarning', 
'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID', 'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'ScalarType', 
'Tester', 'TooHardError', 'True_', 'UFUNC_BUFSIZE_DEFAULT', 'UFUNC_PYVALS_NAME', 
'VisibleDeprecationWarning', 'WRAP', '_CopyMode', '_NoValue', '_UFUNC_API', '__NUMPY_SETUP__', 
'__all__', '__builtins__', '__cached__', '__config__', '__deprecated_attrs__', '__dir__', 
'__doc__', '__expired_functions__', '__file__', '__getattr__', '__git_version__', '__loader__', 
'__name__', '__package__', '__path__', '__spec__', '__version__', '_add_newdoc_ufunc', 
'_distributor_init', '_financial_names', '_from_dlpack', '_globals', '_mat', '_pytesttester', 
'_version', 

'abs', 'absolute', 'add', 'add_docstring', 'add_newdoc', 'add_newdoc_ufunc', 
'alen', 'all', 'allclose', 'alltrue', 'amax', 'amin', 'angle', 'any', 'append', 
'apply_along_axis', 'apply_over_axes', 'arange', 'arccos', 'arccosh', 'arcsin', 
'arcsinh', 'arctan', 'arctan2', 'arctanh', 'argmax', 'argmin', 'argpartition', 
'argsort', 'argwhere', 'around', 'array', 'array2string', 'array_equal', 'array_equiv', 
'array_repr', 'array_split', 'array_str', 'asanyarray', 'asarray', 'asarray_chkfinite', 
'ascontiguousarray', 'asfarray', 'asfortranarray', 'asmatrix', 'asscalar', 'atleast_1d', 
'atleast_2d', 'atleast_3d', 'average', 'bartlett', 'base_repr', 'binary_repr', 'bincount', 
'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'blackman', 'block', 'bmat', 
'bool8', 'bool_', 'broadcast', 'broadcast_arrays', 'broadcast_shapes', 'broadcast_to', 
'busday_count', 'busday_offset', 'busdaycalendar', 'byte', 'byte_bounds', 'bytes0', 
'bytes_', 'c_', 'can_cast', 'cast', 'cbrt', 'cdouble', 'ceil', 'cfloat', 'char', 
'character', 'chararray', 'choose', 'clip', 'clongdouble', 'clongfloat', 'column_stack', 
'common_type', 'compare_chararrays', 'compat', 'complex128', 'complex64', 'complex_', 
'complexfloating', 'compress', 'concatenate', 'conj', 'conjugate', 'convolve', 'copy', 
'copysign', 'copyto', 'core', 'corrcoef', 'correlate', 'cos', 'cosh', 'count_nonzero', 
'cov', 'cross', 'csingle', 'ctypeslib', 'cumprod', 'cumproduct', 'cumsum', 'datetime64', 
'datetime_as_string', 'datetime_data', 'deg2rad', 'degrees', 'delete', 'deprecate', 
'deprecate_with_doc', 'diag', 'diag_indices', 'diag_indices_from', 'diagflat', 'diagonal', 
'diff', 'digitize', 'disp', 'divide', 'divmod', 'dot', 'double', 'dsplit', 'dstack', 'dtype', 
'e', 'ediff1d', 'einsum', 'einsum_path', 'emath', 'empty', 'empty_like', 'equal', 'errstate', 
'euler_gamma', 'exp', 'exp2', 'expand_dims', 'expm1', 'extract', 'eye', 'fabs', 'fastCopyAndTranspose', 
'fft', 'fill_diagonal', 'find_common_type', 'finfo', 'fix', 'flatiter', 'flatnonzero', 'flexible', 
'flip', 'fliplr', 'flipud', 'float16', 'float32', 'float64', 'float_', 'float_power', 'floating', 
'floor', 'floor_divide', 'fmax', 'fmin', 'fmod', 'format_float_positional', 'format_float_scientific', 
'format_parser', 'frexp', 'frombuffer', 'fromfile', 'fromfunction', 'fromiter', 'frompyfunc', 
'fromregex', 'fromstring', 'full', 'full_like', 'gcd', 'generic', 'genfromtxt', 'geomspace', 
'get_array_wrap', 'get_include', 'get_printoptions', 'getbufsize', 'geterr', 'geterrcall', 
'geterrobj', 'gradient', 'greater', 'greater_equal', 'half', 'hamming', 'hanning', 'heaviside', 
'histogram', 'histogram2d', 'histogram_bin_edges', 'histogramdd', 'hsplit', 'hstack', 'hypot', 
'i0', 'identity', 'iinfo', 'imag', 'in1d', 'index_exp', 'indices', 'inexact', 'inf', 'info', 
'infty', 'inner', 'insert', 'int0', 'int16', 'int32', 'int64', 'int8', 'int_', 'intc', 'integer', 
'interp', 'intersect1d', 'intp', 'invert', 'is_busday', 'isclose', 'iscomplex', 'iscomplexobj', 
'isfinite', 'isfortran', 'isin', 'isinf', 'isnan', 'isnat', 'isneginf', 'isposinf', 'isreal', 
'isrealobj', 'isscalar', 'issctype', 'issubclass_', 'issubdtype', 'issubsctype', 'iterable', 
'ix_', 'kaiser', 'kron', 'lcm', 'ldexp', 'left_shift', 'less', 'less_equal', 'lexsort', 'lib', 
'linalg', 'linspace', 'little_endian', 'load', 'loadtxt', 'log', 'log10', 'log1p', 'log2', 
'logaddexp', 'logaddexp2', 'logical_and', 'logical_not', 'logical_or', 'logical_xor', 'logspace', 
'longcomplex', 'longdouble', 'longfloat', 'longlong', 'lookfor', 'ma', 'mask_indices', 'mat', 
'math', 'matmul', 'matrix', 'matrixlib', 'max', 'maximum', 'maximum_sctype', 'may_share_memory', 
'mean', 'median', 'memmap', 'meshgrid', 'mgrid', 'min', 'min_scalar_type', 'minimum', 'mintypecode', 
'mod', 'modf', 'moveaxis', 'msort', 'multiply', 'nan', 'nan_to_num', 'nanargmax', 'nanargmin', 
'nancumprod', 'nancumsum', 'nanmax', 'nanmean', 'nanmedian', 'nanmin', 'nanpercentile', 'nanprod', 
'nanquantile', 'nanstd', 'nansum', 'nanvar', 'nbytes', 'ndarray', 'ndenumerate', 'ndim', 'ndindex', 
'nditer', 'negative', 'nested_iters', 'newaxis', 'nextafter', 'nonzero', 'not_equal', 'numarray', 
'number', 'obj2sctype', 'object0', 'object_', 'ogrid', 'oldnumeric', 'ones', 'ones_like', 'os', 
'outer', 'packbits', 'pad', 'partition', 'percentile', 'pi', 'piecewise', 'place', 'poly', 
'poly1d', 'polyadd', 'polyder', 'polydiv', 'polyfit', 'polyint', 'polymul', 'polynomial', 'polysub', 
'polyval', 'positive', 'power', 'printoptions', 'prod', 'product', 'promote_types', 'ptp', 'put', 
'put_along_axis', 'putmask', 'quantile', 'r_', 'rad2deg', 'radians', 'random', 'ravel', 
'ravel_multi_index', 'real', 'real_if_close', 'rec', 'recarray', 'recfromcsv', 'recfromtxt', 
'reciprocal', 'record', 'remainder', 'repeat', 'require', 'reshape', 'resize', 'result_type', 
'right_shift', 'rint', 'roll', 'rollaxis', 'roots', 'rot90', 'round', 'round_', 'row_stack', 's_', 
'safe_eval', 'save', 'savetxt', 'savez', 'savez_compressed', 'sctype2char', 'sctypeDict', 'sctypes', 
'searchsorted', 'select', 'set_numeric_ops', 'set_printoptions', 'set_string_function', 'setbufsize', 
'setdiff1d', 'seterr', 'seterrcall', 'seterrobj', 'setxor1d', 'shape', 'shares_memory', 'short', 
'show_config', 'sign', 'signbit', 'signedinteger', 'sin', 'sinc', 'single', 'singlecomplex', 
'sinh', 'size', 'sometrue', 'sort', 'sort_complex', 'source', 'spacing', 'split', 'sqrt', 'square', 
'squeeze', 'stack', 'std', 'str0', 'str_', 'string_', 'subtract', 'sum', 'swapaxes', 'sys', 'take', 
'take_along_axis', 'tan', 'tanh', 'tensordot', 'test', 'testing', 'tile', 'timedelta64', 'trace', 
'tracemalloc_domain', 'transpose', 'trapz', 'tri', 'tril', 'tril_indices', 'tril_indices_from', 
'trim_zeros', 'triu', 'triu_indices', 'triu_indices_from', 'true_divide', 'trunc', 'typecodes', 
'typename', 'ubyte', 'ufunc', 'uint', 'uint0', 'uint16', 'uint32', 'uint64', 'uint8', 'uintc', 
'uintp', 'ulonglong', 'unicode_', 'union1d', 'unique', 'unpackbits', 'unravel_index', 'unsignedinteger', 
'unwrap', 'use_hugepage', 'ushort', 'vander', 'var', 'vdot', 'vectorize', 'version', 'void', 'void0', 
'vsplit', 'vstack', 'warnings', 'where', 'who', 'zeros', 'zeros_like']
'''

* 출력 화면

 

 출처

 

 

+ 강의 교재

반응형

'AI Bootcamp > Numpy' 카테고리의 다른 글

[Numpy] 1일차_1차열 배열 추가 및 삭제  (0) 2022.04.19
[Numpy] 1일차_1차원 배열 생성  (0) 2022.04.19
2022-04-11 16:32:42
반응형

FLASK 웹 사이트 만들기 2

 

 

FLASK 웹 사이트 만들기 2

 

1. notion 접속

https://www.notion.so/

2. 새 페이지 생성 후 html 포맷 입력 → 우측 상단 ... 클릭 → Export 클릭

 

3. Export format - HTML → Export 버튼 마우스로 클릭

4. 임의의 경로에 폴더 생성하여 압축 풀기

5. hello로 html 파일 이름 변경

6. html 편집기 다운로드

https://atom.io/

https://notepad-plus-plus.org/downloads/

※ 그냥 구름 IDE 이용해도 됨

https://ide.goorm.io/

7. 전체선택 Ctrl + A → 복사 Ctrl + C

8. 구름 IDE → 프로젝트 hello.html에 전체 복사 → 맨 끝에 코드에 <a> 태그 추가하여 수정 → Ctrl + S로 저장

<a href="/apply">집 등록하기</a>
<a href="/list">등록한 집 목록보기</a>

9. Notion에서 페이지 추가 1

10. Notion에서 페이지 추가 2

11. 집 등록하기 & 리스트 보여주기 Export

12. Export format - HTML → Export 버튼 마우스로 클릭

13. 임의의 경로에 생성한 폴더에 압축 풀기

14. list.html / apply.html로 html 파일 이름 변경

15. html 편집기에서 (list.html / apply.html로 html)을 각각 열어서 전체선택 Ctrl + A → 복사 Ctrl + C

16. 구름 IDE에 동일한 이름의 html 파일 생성하여 전체 복사한 html 코드 붙여넣기

 

 

 출처

 

* FLASK 이미지 : https://ko.wikipedia.org/wiki/%ED%94%8C%EB%9D%BC%EC%8A%A4%ED%81%AC_(%EC%9B%B9_%ED%94%84%EB%A0%88%EC%9E%84%EC%9B%8C%ED%81%AC)

클론코딩 강의  : https://www.youtube.com/watch?v=EPN_NAQsk7M&list=PLqIc89sXpwUBmr0Z282fm9JurDDYBE55r&index=3 

 

반응형

'Python > FLASK' 카테고리의 다른 글

[FLASK] 웹 사이트 만들기 1  (0) 2022.04.11
2022-04-11 14:48:48
반응형

FLASK 웹 사이트 만들기 1

 

 

FLASK 웹 사이트 만들기 1

 

1. 구름 IDE 접속

https://ide.goorm.io/

 

2. 컨테이너 생성

Name : BUILD
Description : house build Web Site
Region : Seoul(KOR)
Visibility : Private
Template : Default Template
Deployment : Not used
Stack : Flask

3. 컨테이너 생성 완료 화면 → Run Container 버튼 마우스로 클릭

4. PROJECT → Running URL and Port

5. Propety → Running URL and Port → Port 80 Delete

6. URL & PORT 입력 후 Register 버튼 마우스로 클릭

URL : https:// housetest
PORT : 5000

7. application.py default code

from flask import Flask
import sys
application = Flask(__name__)


@application.route("/")
def hello():
    return "Hello goorm!"


if __name__ == "__main__":
    application.run(host='0.0.0.0', port=int(sys.argv[1]))

8. templates 폴더 생성 hello.html 생성

<h1>
    hello
</h1>

9. application.py update code

from flask import Flask, render_template
import sys
application = Flask(__name__)


@application.route("/")
def hello():
    return render_template("hello.html")


if __name__ == "__main__":
    application.run(host='0.0.0.0')

10. TERMINAL → python3 application.py 실행 확인

* local일 경우 - http://0.0.0.0:5000/ 링크 클릭
* goorm IDE일 경우 - 11~12번 참고

11. PROJECT → Running URL and Port

12. Propety → Running URL and Port → Registed URL and Port → URL 링크 바로가기 버튼 마우스로 클릭

URL - https://housetest.run.goorm.io

13. 홈페이지 확인

 

 출처

 

* FLASK 이미지 : https://ko.wikipedia.org/wiki/%ED%94%8C%EB%9D%BC%EC%8A%A4%ED%81%AC_(%EC%9B%B9_%ED%94%84%EB%A0%88%EC%9E%84%EC%9B%8C%ED%81%AC)

클론코딩 강의  : https://www.youtube.com/watch?v=hsfibrhGFiM&list=PLqIc89sXpwUBmr0Z282fm9JurDDYBE55r&index=2 

 

반응형

'Python > FLASK' 카테고리의 다른 글

[FLASK] 웹 사이트 만들기 2  (0) 2022.04.11
2022-04-04 10:17:11
반응형

설치

 

 

 Python 설치

 

1. python 설치 진행 - python 사이트 접속

https://www.python.org/

https://www.python.org/downloads/release/python-381/

 

Python Release Python 3.8.1

The official home of the Python Programming Language

www.python.org

 

 

2. python 3.8.1 Windows x86-64 executable installer 다운로드

 

3. python 설치 파일 다운로드 완료되면 실행

 

4. 아래 2가지 체크 후 Customize installation 마우스로 클릭 

- Install launcher for all users (recommended)

- Add Python 3.8 to PATH

5. Next 마우스로 클릭

6. Customize install location 변경 -> Install 버튼 마우스로 클릭

C:\Users\UserName\AppData\Local\Programs\Python\Python38
C:\Python38

7. Python 3.8.1 설치 진행중인 화면 

8. Python 3.8.1 설치 완료

9. 시스템 정보 → 고급 시스템 설정

★ 시스템 정보 단축키 : Windows Key + Pause Key 

10.  시스템 속성 → 고급 → 환경 변수(N)...

11. 환경 변수 → 사용자 변수 → 편집

12. 환경 변수 편집에서 아래 2개의 경로 확인

C:\Python38\Scripts\
C:\Python38\

13. Python 3.8.1 설치된 경로에 정상 설치 여부 확인

 

 PyCharm 설치 및 설정

 

0. Pycharm 설치

https://www.jetbrains.com/pycharm/

https://inpages.tistory.com/99

설치가 되어 있다는 가정하에 설정

1.  File → New Project...

 

2. Previously configured interpreter → [...] 마우스로 클릭

3. Add Python Interpreter → System Interpreter → [...] 마우스로 클릭 → C:\Python38\python.exe 경로 설정 → OK 버튼 마우스로 클릭 → OK 버튼 마우스로 클릭

1. Add Python Interpreter → System Interpreter
2. Add Python Interpreter → [...] 마우스로 클릭 
3. Select Python Interpreter → C:\Python38\python.exe 경로 설정 
4. Select Python Interpreter OK 버튼 마우스로 클릭 
5.  Add Python Interpreter  OK 버튼 마우스로 클릭

4. Location → 우측 폴더 모양 마우스로 클릭

5. Select Base Directory - 경로를 C:\pythonstudy로 설정 후 OK 버튼 마우스로 클릭

6. 프로젝트 명은 python으로 입력 후 Create 버튼 마우스로 클릭

7. 프로젝트 생성 완료

 

 출처

 

 

+ 강의 교재

반응형
2022-03-31 14:52:23
반응형
반응형
2022-03-22 17:20:30
반응형

183. Customers Who Never Order

 

 문제 설명

 

Create table If Not Exists Customers (id int, name varchar(255))
Create table If Not Exists Orders (id int, customerId int)
Truncate table Customers
insert into Customers (id, name) values ('1', 'Joe')
insert into Customers (id, name) values ('2', 'Henry')
insert into Customers (id, name) values ('3', 'Sam')
insert into Customers (id, name) values ('4', 'Max')
Truncate table Orders
insert into Orders (id, customerId) values ('1', '3')
insert into Orders (id, customerId) values ('2', '1')

 

Table: Customers

+-------------+------+
| Column Name | Type |
+-------------+------+
| id          | int  |
| customerId  | int  |
+-------------+------+
id is the primary key column for this table.
customerId is a foreign key of the ID from the Customers table.
Each row of this table indicates the ID of an order and the ID of the customer who ordered it.

 

id는 이 테이블의 프라이머리 키열입니다.
customerId는 [Customers]테이블에 있는 ID의 외부 키입니다.
이 표의 각 행은 주문의 ID와 주문 고객의 ID를 나타냅니다.

 

Write an SQL query to report all customers who never order anything.

Return the result table in any order.

The query result format is in the following example.

SQL 쿼리를 작성하여 아무것도 주문하지 않은 모든 고객을 보고합니다.
임의의 순서로 결과 테이블을 반환합니다.
쿼리 결과 형식은 다음과 같습니다.

 

 입출력 예

 

Example 1:

Input: 
Customers table:
+----+-------+
| id | name  |
+----+-------+
| 1  | Joe   |
| 2  | Henry |
| 3  | Sam   |
| 4  | Max   |
+----+-------+
Orders table:
+----+------------+
| id | customerId |
+----+------------+
| 1  | 3          |
| 2  | 1          |
+----+------------+
Output: 
+-----------+
| Customers |
+-----------+
| Henry     |
| Max       |
+-----------+

 

 Oracle Query

 

select name as customers
from customers
where id not in
(select customerid from orders);

서브쿼리 (select customerid from orders)에서 customerid 결과가 아닌 id일 때, 컬럼 name 출력

* 참고 링크 : https://leetcode.com/problems/customers-who-never-order/discuss/1080196/Oracle-easiest-solution

https://stand-atop.tistory.com/144

 출처

 

https://leetcode.com/problems/customers-who-never-order/

반응형