Review_2_19_class

DODO·2026년 2월 19일

Review_for class

목록 보기
5/20

today review rink
Today the class content is If statement!

1. bools have only two values, T and F

> ex) patient_age = 25
> if patient_age == 18:
> print('he has become an adult')

> ex) is_emergency = False
> if is_emergency:
> print('It is an emergency')

> ex) blood_sugar = 180
> is_diabetes = blood_sugar >= 150
> print(is_diabetes)

2. Basic structure of conditional statements

-if the condition is true, the code executes.
temp = 38.2
if temp >= 37.5:
print('checked fever')
else:
print('no fever')

-if 'a' is false
patient_age=16
if patient_age>=18:
print('prescribe an adult's med')
else:

print('prescribe a children's med')

3. Conditional Operators

비교 연산자 - ex) >, >=, <, <=, ==, !=
포함 연산자 - ex) in , not in
-> A in B : If 'B' contains 'A', That's true.
-> A not in B : If 'B' does not contains 'A', That's true.

4. Logical Operators

and : If all conditions are true,That's true.
or : If at least one condition is true, That's true
not: Inverts the value

5. Ternary Operators

If - else -> result'A' if condition else result'B'
-if condition is true, result'A' is returned
-if condition is false, result'B' is returned

0개의 댓글