코딩/Python
생활코딩) Python 제어문 공부
공부또치
2022. 6. 27. 14:04
728x90
반응형
# 012
print(0)
if True:
print(1)
print(2)
print('---')
#02
print(0)
if False:
print(1)
print(2)
input_ID = input('ID: ')
ID = 'egoing'
if input_ID == ID:
print('Welcome')
#013
print(0)
if True:
print(1)
else:
print(2)
print(3)
print('---')
#013
print(0)
if False:
print(1)
else:
print(2)
print(3)
input_ID = input('ID: ')
ID = 'egoing'
if input_ID == ID:
print('Welcome')
else:
print('who?')
#023
print(0)
if True:
print(1)
elif True:
print(2)
else:
print(3)
print(4)
print('---')
#024
print(0)
if False:
print(1)
elif False:
print(2)
else:
print(3)
print(4)
input_ID = input('ID: ')
ID1 = 'egoing'
ID2 = 'basta'
if input_ID == ID1:
print('Welcome')
elif input_ID == ID2:
print('Welcome')
else:
print('who?')
input_id = input('id: ')
id = 'egoing'
input_password = input('password: ')
password = '111111'
if input_id == id:
if input_password == password:
print('Welcome')
else:
print('Wrong password')
else:
print('Wrong id')
persons = [
['egoing', 'Seoul', 'Web'],
['basta', 'Seoul', 'IOT'],
['blckdew', 'Tongyeong', 'ML']
]
print(persons[0][0])
for person in persons:
print(person[0]+','+person[1]+','+person[2])
name, address, interest = ['egoing', 'Seoul', 'Web']
print(name, address, interest)
for name, address, interest in persons:
print(name+','+address+','+interest)
person = {'name':'egoing', 'address':'Seoul', 'interest':'Web'}
print(person['name'])
for key in person:
print(key, person[key])
persons = [
{'name':'egoing', 'address':'Seoul', 'interest':'Web'},
{'name':'basta', 'address':'Seoul', 'interest':'IOT'},
{'name':'blackdew', 'address':'Tongyeong', 'interest':'ML'}
]
print('==== persons ====')
for person in persons:
for key in person:
print(key, ':', person[key])
print('---------------')

728x90
반응형