weather = input("오늘 날씨 어떤가요?")
if weather == "비" or "눈":
print("우산을 챙기세요")
elif weather == "미세먼지":
print("마스크를 챙기세요")
else:
print("준비물 필요 없어요.")
temp = int(input("온도가 어떤가요"))
if 30 <= temp:
print("너무 덥네요!")
elif 10 < temp and temp < 30:
print("그럭저럭 괜찮네여")
else:
print("너무 춥네요 나가지 말아주세요!")
from random import *
name = "마린"
hp = 40
damage = 5
print("{}유닛이 생성되었습니다.".format(name))
print("체력은{0}, 공격력은 {1}입니다.".format(hp, damage))
tank_name = "탱크"
tank_hp = 150
tank_damage = 35
print("{}유닛이 생성되었습니다.".format(tank_name))
print("체력은{0}, 공격력은 {1}입니다.".format(tank_hp, tank_damage))
tank2_name = "탱크2"
tank2_hp = 150
tank2_damage = 35
print("{}유닛이 생성되었습니다.".format(tank_name))
print("체력은{0}, 공격력은 {1}입니다.".format(tank_hp, tank_damage))
def attack(name, location, damage):
print("{0} : {1} 방향으로 적군을 공격합니다 : {2}".format(name, location, damage))
attack(name, "1시", damage)
attack(tank_name, "1시", tank_damage)
attack(tank2_name, "1시", tank2_damage)
class Unit:
def __init__(self, name, hp, damage, speed):
self.name = name
self.hp = hp
self.damage = damage
self.speed = speed
def move(self, location):
print("[지상유닛 이동]")
print("{0} : {1} 방향으로 이동합니다. [속도 : {2}]"\
.format(self.name, location, self.speed))
marine1 = Unit("마린", 40, 5, 10)
marine2 = Unit("마린2", 40, 5, 10)
tank1 = Unit("탱크", 140, 25, 10)
tank21 = Unit("탱크21", 140, 25, 10)
wraith1 = Unit("레이스", 80, 5, 10)
print("클래스 외부 호출입니다. 유닛 이름 : {0}, 공격력 : {1}".format(wraith1.name, wraith1.hp))
wraith2 = Unit("빼앗은 레이스", 80, 5, 10)
wraith2.clocking = True
if wraith2.clocking == True:
print("{0}는 현재 클로킹 상태입니다.".format(wraith2.name))
class AttackUnit(Unit):
def __init__(self, name, hp, damage, speed):
Unit.__init__(self, name, hp, damage, speed)
self.name = name
def attack(self, location):
print("{0} : {1} 방향으로 적군을 공격한다. [공격력 : {2}]"\
.format(self.name, location, self.damage))
def damaged(self, damage):
print("{0} : {1} 데미지를 입었습니다.".format(self.name, damage))
self.hp -= damage
print("{0} : 현재 체력은 {1} 입니다.".format(self.name, self.hp))
if self.hp <= 0:
print("{0} : 파괴되었습니다".format(self.name))
firebat1 = AttackUnit("파이어뱃", 50, 16, 10)
firebat1.attack("5시")
firebat1.damaged(25)
firebat1.damaged(25)
class Flyable:
def __init__(self, flying_speed):
self.flying_speed = flying_speed
def fly(self, name, location):
print("{0} : {1} 방향으로 날아갑니다 : [속도 : {2}]"\
.format(name, location, self.flying_speed))
class FlyableAttackUnit(AttackUnit, Flyable):
def __init__(self, name, hp, damage, flying_speed):
AttackUnit.__init__(self, name, hp, damage, flying_speed)
Flyable.__init__(self, flying_speed)
def move(self, location):
print()
self.fly(self.name, location)
valkirie1 = FlyableAttackUnit("발키리1", 250, 15, 5)
valkirie1.fly(valkirie1.name, "3시")
vulture = AttackUnit("벌쳐", 80, 10, 10)
vulture.move("11시")
battlecruiser = FlyableAttackUnit("배틀크루저", 500, 25, 3)
battlecruiser.move("9시")
class BuildingUnit(Unit):
def __init__(self, name, hp, location):
pass
supply_depot = BuildingUnit("서플라이 디폿", 500, "7시")
def game_start():
print("새로운 게임을 시작합니다.")
def game_over():
pass
game_start()
game_over()
class BuildingUnit1(Unit):
def __init__(self, name, hp, location):
super().__init__(name, hp, 0)
self.location = location
class Unit1:
def __init__(self):
print("유닛1 생성자")
class Flyable1:
def __init__(self):
print("Flyable 생성자")
class FlyableUnit1:
def __init__(self):
super().__init__()
dropship = FlyableUnit1()
class Marine(AttackUnit):
def __init__(self):
AttackUnit.__init__(self, "마린", 40, 1, 5)
def stimpack(self):
if self.hp > 10:
self.hp -= 10
print("스팀팩을 사용했습니다.")
else:
print("체력이 부족합니다.")
class Tank(AttackUnit):
seize_developed = False
def __init__(self):
AttackUnit.__init__(self, "탱크", 150, 1, 5)
self.seize_mode = False
def set_seize_mode(self):
if Tank.seize_developed == False:
print("시즈모드를 업그레이드 해주십시오.")
return
if self.seize_mode == False:
print("시즈모드를 전환합니다.")
self.damage *= 2
self.seize_mode = True
else:
self.damage /= 2
self.seize_mode = False
def game_start():
print("게임이 시작되었습니다.")
def game_over():
print("게임이 끝났습니다.")
game_start()
m1 = Marine()
m2 = Marine()
m3 = Marine()
m4 = Marine()
t1 = Tank()
t2 = Tank()
t3 = Tank()
attack_units = []
attack_units.append(m1)
attack_units.append(m2)
attack_units.append(m3)
attack_units.append(m4)
attack_units.append(t1)
attack_units.append(t2)
attack_units.append(t3)
for unit in attack_units:
unit.move("1시")
Tank.seize_developed = True
print("시즈모드 개발이 완료되었습니다.")
for unit in attack_units:
if isinstance(unit, Marine):
unit.stimpack()
elif isinstance(unit, Tank):
unit.set_seize_mode()
for unit in attack_units:
unit.attack("1시")
for unit in attack_units:
unit.damaged(randint(5, 21))
game_over()
class House:
def __init__(self, location, house_type, deal_type, price, completion_year):
self.location = location
self.house_type = house_type
self.deal_type = deal_type
self.price = price
self.completion_year = completion_year
def show_detail(self):
print(self.location, self.house_type, self.deal_type, self.price, self.completion_year)
houses = []
house1 = House("강남", "아파트", "매매", "10억", "2010년")
house2 = House("마포", "오피스텔", "전세", "5억", "2007년")
house3 = House("송파", "빌라", "월세", "500/50", "2000년")
houses.append(house1)
houses.append(house2)
houses.append(house3)
print("총 {0} 대의 매물이 있습니다.".format(len(houses)))
for house in houses:
house.show_detail()