# 변수선언
var_int = 1
var_double = 1.1
var_str = "str_1" # 큰따옴표("), 작은따옴표(') 구분 없음
var1, var2 = 1, 2 # 두개 동시에 선언
var_bool = 1 < 2 # True
# 자료형 타입
type(3) # 출력 : <class 'int'>
type(3.1) # 출력 : <class 'float'>
type("Str") # 출력 : <class 'str'>
type(True) # 출력 : <class 'bool'>
# 복합 연산자
num = 1
num += 1 # 2
# 연산자_Plus
3**2 # 9
3/2 # 1.5
3//2 # 1
##################################
# ** : 거듭제곱
# / : 실수형 나눗셈
# // : 정수형 나눗셈
##################################
# 프린트
print("test str :", var_str) # 출력 > test str : var_str
#. 함수
def func_01(name, num):
print(name, ":", num) # 들여쓰기로 함수코드 구분
return num
rtn01 = func_01("test", 3)
print(rtn01)
# 출력 ###########################
# test : 3
# 3
##################################
# 사용자 입력(input)
str = input("How old are you : ")
print(str)
# 출력 ###########################
# How old are you : 3(입력값)
# 3
# --------------------------------
# * 문자열로만 받아진다.
##################################
[ bool True 값 규칙 ]
- 데이터가 존재하는 컬렉션이나 문자열은 True
- 0이 아닌 숫자 True
[ 다항 비교 ]
>>> x = y = z = 3
>>> x == y == z # True
>>> 0 < x < 100 # True'Python > 기초이론' 카테고리의 다른 글
| Python - 튜플 (0) | 2022.12.25 |
|---|---|
| Python - for, while (0) | 2022.12.24 |
| Python - if (0) | 2022.12.24 |
| Python - 문자열 (0) | 2022.12.10 |
| Python - 리스트 (0) | 2022.12.10 |