number = 10
NameError: name 'num' is not defined
카멜 표기법: customerBankAccount
스네이크 표기법: customer_bank_account
import keyword
print(keyword.kwlist)
자료형(Data type): int, float, str, bool
//정수는 메모리가 허용되는 한 무한 사용 가능, 실수는 데이터 손실o(소수점 이하 17~18번째에서)
포맷문자열
userName = '홍길동'
print(f'User Name: {userName}')
print('User name: {}, User age: {}'.format(userName, userAge))
논리 연산자: and, or, not
산술 연산자: +, -, *, /, %, //, **
할당 연산자: =, +=, -=, *=, /=, %=, //=
비교 연산자: >, >=, <, <=, ==, !=_
ZeroDivisionError: Devision by zero
나눗셈 결과는 항상 float
거듭제곱 연산자: **
n의 m제곱근 공식: n**(1/m)
math 모듈
import math
num1 = math.sqrt(2) #2의 제곱근
num2 = math.pow(2, 3) #2의 3제곱
ord('A') -> 65
chr(65) -> A
if 10 > 5:
print('10은 5보다 크다.')
IndentationError: expected an indented block
for i in range(1, 101): if i%3 == 0: print(i)
endNum = 10 n = 0 while n <= endNum: #while 조건식 print(n) #실행문 n += 1
continue: 이하 반복 실행을 생략하고 다음 반복 실행문으로 넘어간다.
break: 반복문 빠져나온다.
pass: 나중에 설정.
천 단위 구분
print(format(1234567890, ','))