본문 바로가기

분류 전체보기

Python Numbers 파이썬 수치형 1. 수치형 Numbers 파이썬 수치형은 세 가지가 있다. - int 정수형 - float 실수형 - complex 복소수형 x = 1 # int y = 2.8 # float z = 1j # complex 실수형은 익스포넨셜을 이용해 나타낼 수도 있다. x = 35e3 y = 12E4 z = -87.7e100 print(type(x)) print(type(y)) print(type(z)) 복소수형은 실수부와 허수부를 나뉘어 허수부에는 'j'를 붙여서 표시한다. x = 3+5j y = 5j z = -5j print(type(x)) print(type(y)) print(type(z)) 2. 형 변환 Type Conversion int(), float(), complex() 메서드를 이용해 형 변환을 할 수..
Python Data Types 파이썬 데이터 타입 https://www.w3schools.com/python/python_datatypes.asp Python Data Types Python Data Types Built-in Data Types In programming, data type is an important concept. Variables can store data of different types, and different types can do different things. Python has the following data types built-in by default, in these categories: www.w3schools.com 파이썬은 변수를 정의할 때 데이터 타입을 명시하지 않지만 그렇다고 데이터 타입이 없는 것은 ..
Python Variables 파이썬 변수 https://www.w3schools.com/python/python_variables.asp 1. 변수 선언과 정의 파이썬의 변수는 정의와 동시에 선언된다. 다시 말해 선언 따로 정의 따로 할 수 없다는 말이다. 희한하게 타입도 없다. 그래서 아래와 같이 변수를 선언+정의한다. x = 5 y = "Hello, World!" x, y, z = "Orange", "Banana", "Cherry" x = y = z = "Orange" 문자열을 정의할 때는 큰 따옴표, 작은따옴표 둘 다 사용이 가능하다. 특이한 것은 파이썬의 모든 변수는 객체라는 것이다. 2. 출력 x = 5 y = 10 print(x + y) x = "Python is " y = "awesome" z = x + y print(z) 문자열은..
Python Comment 파이썬 주석 파이썬의 주석 코드는 '#'으로 시작한다. #This is a comment. print("Hello, World!") 파이썬은 원래 여러 줄을 주석 처리하는 방법이 없다. 잉?! 왜? 그래서 매 줄마다 앞에 '#'을 붙여 줘야 한다. 귀찮다. 그러나 역시나 인류는 꼼수를 찾아냈다. """ This is a comment written in more than just one line """ print("Hello, World!") 이렇게 큰 따옴표나 작은 따옴표 세 개 이상으로 묶으면 여러 줄 주석을 작성할 수 있다.
Python Syntax 파이썬 기본 문법(실행, 들여쓰기) https://www.w3schools.com/python/python_syntax.asp Python Syntax Python Syntax Execute Python Syntax As we learned in the previous page, Python syntax can be executed by writing directly in the Command Line: >>> print("Hello, World!") Hello, World! Or by creating a python file on the server, using the .py file extension www.w3schools.com 1. 파이썬 코드 실행하기 파이썬 코드를 실행하는 방법은 두 가지가 있다. 하나는 커맨드 라인으로 실행하..