1. Boolean
#boolean의 데이터 값은 참 거짓 단 2개뿐이다~
print(True)
print(False)
2. Comparison Operator
print('1 == 1', 1 == 1)
print('1 == 2', 2 == 1)
print('1 < 2', 1 < 2)
print('1 > 2', 1 > 2)
print('1 >= 1', 1 >= 1)
print('2 >= 1', 2 >= 1)
print('1 != 1', 1 != 1)
print('2 != 1', 2 != 1)

3. Conditional Statement
# 012
print(0)
if True:
print(1)
print(2)
print('---')
# 02
print(0)
if False:
print(1)
print(2)
input_id = input('id: ')
id = 'Myoung'
if input_id == id:
print("welcome")

# 013
print(0)
if True:
print(1)
else:
print(2)
print(3)
print('---')
# 023
print(0)
if False:
print(1)
else:
print(2)
print(3)
# 014
print(0)
if True:
print(1)
elif True:
print(2)
else:
print(3)
print(4)
print('---')
# 024
print(0)
if False:
print(1)
elif True:
print(2)
else:
print(3)
print(4)
print('---')
# 034
print(0)
if False:
print(1)
elif False:
print(2)
else:
print(3)
print(4)
4. Loop
반복문과 꼭 함께 다뤄야 하는 리스트(List)
반복문과 리스트는 단짝입니다!
리스트 안에 있는 요소들을 하나씩 꺼내서 반복적으로 처리해야 할 때 for문을 함께 사용합니다.
for 변수 in 리스트 이런 느낌으로 씁니당!
names = ['Myoung', 'HyunQ', 'Lee', 'Kim']
for name in names:
print('Hello, '+name+' . Bye, '+name+'.')
Multi_Demensional Loop
persons = [
['Myoung', 'Suwon', 'WEB'],
['HyunQ', 'Somewhere', 'WEB'],
['Lee', 'Seoul', 'Rev'],
]
print(persons[0][0])
for person in persons:
print(person[0] + ', ' + person[1] + ', ' + person[2])
person = ['Kim', 'Incheon', 'PWN']
name = person[0]
address = person[1]
interest = person[2]
print(name, address, interest)
name, address, interest = ['Rad', 'Boston', 'Mobile']
print(name, address, interest)
for name, address, interest in persons:
print(name + ', ' + address + ', ' + interest)

Dictionary_Loop
person = {'name':'Myoung', 'address':'Suwon', 'interest':'WEB'}
print(person['name'])
for key in person:
print(key, person[key])
persons = [
{'name':'Daniel', 'address':'Seoul', 'interest':'Web'},
{'name':'Woow', 'address':'Seoul', 'interest':'IOT'},
{'name':'Gini', 'address':'Tongyeong', 'interest':'REV'}
]
print('==== persons =====')
for person in persons:
for key in person:
print(key, ':', person[key])
print('-------------')

'Python > Python Basic' 카테고리의 다른 글
| 생활코딩-Python 입문 수업 (0) | 2025.03.07 |
|---|---|
| Week1 - Python Basic (0) | 2024.04.12 |