django 1주 숙제 ⭐

Grace Goh·2022년 9월 22일
0

Django

목록 보기
2/32

project_01.py

my_station = ['야탑', '모란', '이매', '선릉', '한티', '왕십리']

def station_list(station_list):
    for station in station_list:
        print(station)

station_list(my_station)


def station_point(station_list):
    for station in station_list:
        if station == '선릉':
            print(station)

station_point(my_station)

내가 쓴 답

my_station = ['야탑', '모란', '이매', '선릉', '한티', '왕십리']

def station_list():
    for station in my_station:
        print(station)

station_list()


def station_point():
    for station in my_station:
        if station == '선릉':
            return station

seolleung = station_point()
print(seolleung)

project_02.py

# Post 글 클래스 작성
class Post: 
		# 변수들을 초기화
    id = '' 
    title = ''
    author = ''
    content = ''


post = Post()
post.id = '1'
post.title = '첫 게시글'
post.author = 'sparta'
post.content = '나의 첫 python Class 게시글은 sparta에서'

print(post)
print("id -> ", post.id)
print("title -> ", post.title)
print("author -> ", post.author)
print("content -> ", post.content)

내가 쓴 답

class SavePost():
    id = ''
    title = ''
    author = ''
    content = ''

mypost = SavePost()
mypost.id = 'gracej'
mypost.title = 'your face'
mypost.author = 'grace'
mypost.content = "Everyone is different, everything is beautiful."
profile
Español, Inglés, Coreano y Python

0개의 댓글