반응형
조건 (Conditions)
print(2 > 3)
결과: False
var_one = 1
var_two = 2
print(var_one < 1)
print(var_two >= var_one)
결과: False
True
기호(Symbol) | 의미 |
== | 같다 (equals) |
!= | 같지 않다 (does not equal) |
< | 작다 (less than) |
<= | 작거나 같다 (less than or equal to) |
> | 크다 (greater than) |
>= | 크거나 같다 (greater than or equal to) |
조건문(Conditional Statements)
"if" 조건문
def evaluate_temp(temp):
# Set an initial message
message = "Normal temperature."
# Update value of message only if temperature greater than 38
if temp > 38:
message = "Fever!"
return message
print(evaluate_temp(37))
결과: Normal temperature.
print(evaluate_temp(39))
결과: Fever!
"if ... else" 조건문
def evaluate_temp_with_else(temp):
if temp > 38:
message = "Fever!"
else:
message = "Normal temperature."
return message
print(evaluate_temp_with_else(37))
결과: Normal temperature.
"if ... elif ... else" 조건문
def evaluate_temp_with_elif(temp):
if temp > 38:
message = "Fever!"
elif temp > 35:
message = "Normal temperature."
else:
message = "Low temperature."
return message
evaluate_temp_with_elif(36)
결과: Normal temperature.
evaluate_temp_with_elif(34)
결과: Low temperature.
<< 참조 >>
https://www.kaggle.com/code/alexisbcook/conditions-and-conditional-statements
Conditions and Conditional Statements
Explore and run machine learning code with Kaggle Notebooks | Using data from No attached data sources
www.kaggle.com
반응형
'프로그램 개발해서 돈벌기 > AI' 카테고리의 다른 글
AI로 그림 그리기 : Playground AI (0) | 2023.02.14 |
---|---|
파이션(python) 초등 완전 기초: 리스트 (Lists) (0) | 2023.02.12 |
파이션(python) 초등 완전 기초: 데이타 타입(Data Types) (0) | 2023.02.09 |
파이션(python) 초등 완전 기초: 함수(Function) (0) | 2023.02.09 |
파이션(python) 초등 완전 기초: 연산과 변수 (0) | 2023.02.07 |
댓글