- 숙제 1.
1. project_01.py를 만들고, 주어진 데이터를 반복문으로 모두 출력하는 station_list 함수를 작성하세요
데이터 : my_station=['야탑','모란','이매','선릉','한티','왕십리']
2. proejct_01.py에 주어진 데이터를 반복문과 조건문을 사용하여 '선릉'만 출력 하는 station_point 함수를 작성하세요
- 숙제 1. 결과
my_station = ['야탑', '모란', '이매', '선릉', '한티', '왕십리']
def station_list(station_var):
for station in station_var:
print(station)
# 함수명 호출하면서 station_var 라는 매개변수 안에 리스트들어가게됨. my_station = station_var
station_list(my_station)
def station_point(station_var):
for station in station_var:
if station == '선릉':
print(station)
station_point(my_station)
* 포인트 :
함수명 호출하면서 station_var 라는 매개변수 안에 리스트들어가게됨. my_station = station_var
- 숙제 2.
proejct_02.py에 게시글을 저장하는 class를 만들려고 합니다. 클래스 안에 들어갈 변수는 ( id, title, author, content) 으로 모두 빈 문자열로 저장하고, 게시글 한 개를 저장해 보세요!
- 숙제 2. 결과
class post:
id = ''
title = ''
author = ''
content = ''
first_post = post()
first_post.id = 'thisisid'
first_post.title = 'thisistitle'
first_post.author = 'thisisauthor'
first_post.content = 'thisiscontent'
print(first_post)
print(first_post.id)
print(first_post.title)
print(first_post.author)
print(first_post.content)
* 포인트 : 클래스 선언 변수.
'AI 웹 개발 과정 > 파이썬 장고 실무 기초' 카테고리의 다른 글
06. 3주차 실습 및 숙제 - 게시글 쓰기, 읽기, 삭제 / 댓글 추가 (0) | 2022.05.30 |
---|---|
05. 3주차 이론 - (0) | 2022.05.30 |
04. 2주차 실습 및 숙제 - (1) | 2022.05.27 |
03. 2주차 이론 - Django APP / SQLite3 / ORM / model 추가 / admin (0) | 2022.05.27 |
01. 1주차 이론 - 파이썬 기초 문법 / Django 알아보기 (0) | 2022.05.26 |