양식은 제한 없으니 내용 자유롭게 채워주세요!
백준 1 주차
2557번 문제
print("Hello World!")
10869번 문제
a,b =map(int,input().split())
print(a + b)
print(a - b)
print(a * b)
print(int(a / b))
print(a % b)
10926번 문제
a = input()
b ='??!'
print("{}{}".format(a,b))
18108번 문제
a = int(input())
result = a - 543
print(result)
3046번 문제
r1,s=map(int,input().split())
r2 = 2*s - r1
print(r2)
1330번 문제
a,b = map(int,input().split())
if a > b :
print('>')
elif a < b :
print('<')
elif a == b:
print('==')
# 이론 문제 1-1 [5점]
class person:
def __init__(self, age, height, weight):
self.age=age
self.height=height
self.weight=weight
print("이 사람은 {0}살이고, 키는 {1}cm이며, 몸무게는 {2}kg입니다".format(self.age, self.height, self.weight))
chulsu=person(23,182,73)
younghee=person(23,166,50)
chulsu.crying =True
답 : X
person의 인자는 age,height,weight로 3개이다.
# 이론 문제 1-2 [5점]
class joker:
def laugh(self):
print('Haahahahahaa')
chulsu =joker()
chulsu.laugh()
실행 시 철수가 웃습니다.
위 코드가 맞으면 o, 틀리면 x 표시한 후 고치시오.
답 : O
# 이론 문제 1-3 [5점]
class StudentUnit:
def __init__(self,name,score):
self.name = name
self.score = score
def subject(self,title):
print("{0} 학생의 {1} 과목 점수는 {2} 점 입니다.".format(self.name,title,self.score))
student = StudentUnit("짱구",35)
student.title("수학")
위 코드를 실행하면 '짱구 학생의 수학 과목 점수는 35 점 입니다.'가 출력된다.
맞으면 o, 틀리면 x 표시한 후 고치시오.
답 : X
student.title("수학)을 student.subject("수학")으로 바꾸면 된다.
# 이론 문제 1-4 [5점]
1.
class Unit:
def __init__(self,name,station):
self.name = name
self.station = station
def time(self,time):
print("{0}은 {1}에 {2}시에 도착합니다.".format(self.name,self.station,time))
subway = Unit("7호선","어린이대공원역")
subway.time(4)
출력 : 7호선은 어린이대공원역에 4시에 도착합니다.
2.
class Unit:
def __init__(self,name,station):
self.name = name
self.station = station
def time(self,time):
print("{0}은 {1}에 {2}시에 도착합니다.".format(self.name,self.station,self.time))
subway = Unit("7호선","어린이대공원역")
subway.time(4)
출력 : self.time 때문에 에러 , self.time 으로 쓰면 안됨
1번과 2번 코드의 출력 결과는 같다.
맞으면 o, 틀리면 x 표시한 후 고치시오.
답 : X
# 이론 문제 2-1 [8점]
class Menu:
def __init__(self, name, price):
self.name = name
self.price = price
class Menu_Size(Menu):
def __init__(self, name, size, price):
self.size = size
def Order(self, number):
print("{0} {1}개 {2}사이즈로 주문.".format(self.name, number, self.size))
def Price(self):
print("{0}원 입니다.".format(self.price))
ice_americano = Menu_Size("아이스아메리카노", "tall", 5000)
ice_americano.Order(1)
ice_americano.Price()
'아이스아메리카노 2개 tall사이즈로 주문.'
'5000원 입니다.'
가 출력되도록 고치시오.
# 이론 문제 2-2 [6점]
class Unit:
def __init__(self,name,money):
self.name = name
self.money = money
class SadUnit(Unit):
def __init__(self,name,money,location):
Unit.__init__(self,name,money)
self.location = location
def earn(self,debt):
print("{0}는 {1}에서 {2}원을 벌었지만 {3}원의 빚이 있었다.".format(self.name,self.location,self.money,debt))
jaeha = SadUnit("재하", 1000, "롯데리아")
jaeha.earn(2000)
위의 코드를 <재하는 롯데리아에서 1000원을 벌었지만 2000원의 빚이 있었다.> 가 출력되도록 코드를 추가하여 마무리하시오.
# 이론 문제 2-3 [6점]
class Person:
def greeting(self):
print('안녕하세요!!')
class University:
def manage_credit(self):
print('시험공부 엉엉')
class Undergraduate(Person, University):
def study(self):
print('공부하자 공부')
chulsu = Undergraduate()
chulsu.greeting()
chulsu.manage_credit()
chulsu.study()
위 코드 실행 시 '안녕하세요!!', '시험공부 엉엉', '공부하자 공부'가 각각 세 줄로 출력되도록 고치시오.
# 이론 문제 2-4 [5점]
기존의 매소드를 불러와 사용하는 것을 메소드 오버라이딩이라 한다.
맞으면 o, 틀리면 x 표시하시오.
답 : X
# 이론 문제 2-5 [5점]
class Unit:
def __init__(self, name, hp):
self.name = name
self.hp = hp
class DamagedUnit(Unit):
def __init__(self, name, hp):
Unit.__init__(self, name, hp)
print("{}유닛이 생성되었습니다.".format(self.name))
def damaged(self, damage):
self.hp -= damage
if self.hp <= 0:
print("{}는 파괴되었습니다.".format(self.name))
else :
print("{}이 {}만큼 데미지를 입었습니다. \\n{}의 현재 체력은 {}입니다.".format(self.name, damage, self.name, self.hp))
archer = DamagedUnit("아처", 100)
archer.damaged(20)
위 코드 중 틀린 부분을 바르게 고쳐 실행되도록 하시오.
답 : archer.damaged(20)로 수정