코딩 초보 도전기
-
파이썬(PYTHON) 초보 - 복습 / 조건문코딩 초보 도전기 2024. 4. 15. 10:37
조건문은 어떤 특정 조건에 따라 실행되는 명령이 달라지는 구문이다. 조건이 True 일때 명령이 실행되도록 하는데 if 문에 들어갈 명령들은 들여쓰기로 구분을 한다. 조건이 만족하지 않는 경우는 else 로 표기를 할 수 있다. 추가로, 첫 번째 조건이 True 이면 if 문을 작성하고 첫 번째 조건이 False 이면서 두 번째 조건이 True 이면 elif 문을 실행한다. 모든 조건이 False 라면 마지막에 else문을 작성하면서 if - elif - elif - else 문을 실행할 수 있다.
-
파이썬(PYTHON) 기초 - 복습 / input() , 형 변환코딩 초보 도전기 2024. 4. 14. 22:22
print() 가 출력이라면 입력하는 것도 존재한다. 변수와 함께 사용되는데, 변수 = input() input()은 "문자열"로 입력 받아져서 숫자로 가공이 필요한 경우가 있다. 이때, 자료형을 변환시켜야 하는데 바꿀자료형(바뀔자료) 로 입력한다. 예를 들어, 변수 a가 문자열 "100" 이고 변수 b는 문자열 100을 숫자형으로 변형하면 표기는 아래와 같다. a = "100" b = int("100") print(a,b) 를 하게 되면 각 100 100 이 출력되지만 문자형을 보면 print(type(a)) , print(type(b)) 는 각 , 로 문자열, 숫자로 구분되어 진다.
-
파이썬(PYTHON) 기초 - 복습 / 슬라이싱 & 인덱싱코딩 초보 도전기 2024. 4. 14. 22:06
문자열과 리스트에는 순서가 있다. "HELLO"와 "HELOL"는 다른 문자열이고 [1,2,3,4,5] 와 [1,3,2,4,5]도 다른 리스트 이다. 순서가 다르기 때문! 각각 위치를 0부터 순서대로 매길 수 있는데 이것을 인덱스 라고 한다. "HELLO"의 인덱스는 H는 0, E는 1, L은 2, L은 3, O는 4 [1,2,3,4,5] 도 동일하게 1은 0, 2는 1, 3은 2, 4는 3, 5는 4 이러한 인덱스를 활용해서 리스트나 문자열의 특정 위치의 원소를 가져올 수 있는데 이를 '인덱싱' 이라고 한다. A = "HELLO" 변수 A에 HELLO를 저장 후 print(A[3]) 을 하게 되면 3번째 값인 L 이 출력된다. 일부분을 잘라서 가져올 수 있는데 이를 '슬라이싱' 이라고 한다. 상단 예로..
-
파이썬(PYTHON) 기초 - 복습 / 변수 & 사칙연산코딩 초보 도전기 2024. 4. 14. 21:06
변수(variable) : 자료를 보관하는 저장 장소 이다. 즉, 변수이름은 자료와 동일하다고 생각하면 된다. name = "홍길동" grade = ["A+", "A+", A0"] num = 100 처럼 문자열, 리스트, 숫자를 저장할 수 있다. 변수는 숫자, 알파벳, 한글, 언더바(_) 등을 사용할 수 있지만 예외사항이 있다. 1) 숫자로 시작하면 x 2) 파이썬 문법에서 사용되는 예약어는 사용 x (for, while, if 등) 3) 공백문자(""), 연산자(+, - , * 등) 사용 x 자료형은 연산도 가능하다. 사칙연산 (덧셈, 뺄셈, 곱셈, 나눗셈) 표기는 덧셈 + , 뺼셈 -, 곱셈 * , 나눗셈 / 으로 표기한다. print(4+4) print(4-4) print(4*4) print(4/4..
-
파이썬(PYTHON) 기초 - 복습 / 기본 자료형코딩 초보 도전기 2024. 4. 12. 23:20
파이썬에는 기본자료형이 있는데, 대표적으로 아래와 같다. 1) 숫자형 (Number) 숫자로 이루어진 자료형 정수나 실수 등을 다룰 수 있다. 숫자끼리의 연산이 가능하다. 숫자형 종류 ex) 3 은 정수(integer) 3.14는 실수(float) 3+14j 는 복소수 2) 문자열 (String) 문자나 문자들을 늘어놓은 것이며, 큰 따옴표(“”)와 작은 따옴표(ʻʼ)로 구분 그러나 큰 따옴표("")를 사용하는 것을 선호한다. ex) "23" '안녕하세요' 3) 리스트 (List) 여러 자료를 보관하는 자료형 다른 종류의 자료를 함께 담을 수 있으며, 자료 안에 순서가 있다. ex) [ ] ["1", "2"] ["a", "1"] [["a", "b"], "d", 100] 4) 주석 (Comment) 주석은..
-
파이썬(PYTHON) 기초 - 복습 / print문 사용하여 삼행시 짓기코딩 초보 도전기 2024. 4. 12. 23:05
파이썬(PYTHON) 프로그램에서 원하는 정보다 자료를 컴퓨터가 '출력'하게 하기 위해서는'print' 를 사용한다. print("안녕하세요")를 실행한다면 결과는 안녕하세요 라고 나온다. print(55, "Hello") 를 실행한다면 결과는 55 Hello 라고 나온다. print 문을 사용하여 3행시를 짓는다면 ? * 키워드 : 비행기 1) print문의 행을 구분하여 출력하는 방법 2) 여러 문자열을 """ """ 쌍따옴표로 둘러싸서 한 번에 출력하는 방법 3) 이스케이프 코드 \n 을 통해서 개행 * 실제 입력시 '원'모양으로 입력된다. 4) f-string과 이스케이프 코드 \n을 사용하여 각 문자열을 개별적으로 출력하는 방법 5) 문자열을 리스트에 담고 join() 함수를 사용하여 줄바꿈 문..
-
인공지능(AI), 코딩 그리고 파이썬(PYTHON)코딩 초보 도전기 2024. 4. 12. 22:34
인공지능(AI), 코딩 그리고 파이썬(PYTHON) 요즘 저의 최대 관심사 입니다. 제조업 해외영업팀에서 약 10년간의 일을 하면서 코딩이라는 단어를 들었을 때는 코딩=나와 상관없는것 이라고 생각했습니다. 그러나 코로나 시기 이후 뉴노멀(new normal) 시대에 들어서면서 인공지능(AI)분야가 사회적, 국제적으로 많은 이슈화가 되는 것을 느꼈죠. 다가오는 인공지능 시대에 코딩과 같이 프로그래밍 언어를 안다는 것은 필수적인 부분이고 빠른 사회적 변화에 알맞는 직업을 갖고싶었고 미래가 있는 분야라고 생각하고 있어 파이썬(PYTHON)을 배워보려고 합니다. 그렇다면 파이썬(PYTHON)이란 무엇일까요? 위키피디아의 설명을 따르면, 파이썬(영어: Python)은 1991년 네덜란드계 소프트웨어 엔지니어인 귀..