모바일 오유 바로가기
http://m.todayhumor.co.kr
분류 게시판
베스트
  • 베스트오브베스트
  • 베스트
  • 오늘의베스트
  • 유머
  • 유머자료
  • 유머글
  • 이야기
  • 자유
  • 고민
  • 연애
  • 결혼생활
  • 좋은글
  • 자랑
  • 공포
  • 멘붕
  • 사이다
  • 군대
  • 밀리터리
  • 미스터리
  • 술한잔
  • 오늘있잖아요
  • 투표인증
  • 새해
  • 이슈
  • 시사
  • 시사아카이브
  • 사회면
  • 사건사고
  • 생활
  • 패션
  • 패션착샷
  • 아동패션착샷
  • 뷰티
  • 인테리어
  • DIY
  • 요리
  • 커피&차
  • 육아
  • 법률
  • 동물
  • 지식
  • 취업정보
  • 식물
  • 다이어트
  • 의료
  • 영어
  • 맛집
  • 추천사이트
  • 해외직구
  • 취미
  • 사진
  • 사진강좌
  • 카메라
  • 만화
  • 애니메이션
  • 포니
  • 자전거
  • 자동차
  • 여행
  • 바이크
  • 민물낚시
  • 바다낚시
  • 장난감
  • 그림판
  • 학술
  • 경제
  • 역사
  • 예술
  • 과학
  • 철학
  • 심리학
  • 방송연예
  • 연예
  • 음악
  • 음악찾기
  • 악기
  • 음향기기
  • 영화
  • 다큐멘터리
  • 국내드라마
  • 해외드라마
  • 예능
  • 팟케스트
  • 방송프로그램
  • 무한도전
  • 더지니어스
  • 개그콘서트
  • 런닝맨
  • 나가수
  • 디지털
  • 컴퓨터
  • 프로그래머
  • IT
  • 안티바이러스
  • 애플
  • 안드로이드
  • 스마트폰
  • 윈도우폰
  • 심비안
  • 스포츠
  • 스포츠
  • 축구
  • 야구
  • 농구
  • 바둑
  • 야구팀
  • 삼성
  • 두산
  • NC
  • 넥센
  • 한화
  • SK
  • 기아
  • 롯데
  • LG
  • KT
  • 메이저리그
  • 일본프로야구리그
  • 게임1
  • 플래시게임
  • 게임토론방
  • 엑스박스
  • 플레이스테이션
  • 닌텐도
  • 모바일게임
  • 게임2
  • 던전앤파이터
  • 마비노기
  • 마비노기영웅전
  • 하스스톤
  • 히어로즈오브더스톰
  • gta5
  • 디아블로
  • 디아블로2
  • 피파온라인2
  • 피파온라인3
  • 워크래프트
  • 월드오브워크래프트
  • 밀리언아서
  • 월드오브탱크
  • 블레이드앤소울
  • 검은사막
  • 스타크래프트
  • 스타크래프트2
  • 베틀필드3
  • 마인크래프트
  • 데이즈
  • 문명
  • 서든어택
  • 테라
  • 아이온
  • 심시티5
  • 프리스타일풋볼
  • 스페셜포스
  • 사이퍼즈
  • 도타2
  • 메이플스토리1
  • 메이플스토리2
  • 오버워치
  • 오버워치그룹모집
  • 포켓몬고
  • 파이널판타지14
  • 배틀그라운드
  • 기타
  • 종교
  • 단어장
  • 자료창고
  • 운영
  • 공지사항
  • 오유운영
  • 게시판신청
  • 보류
  • 임시게시판
  • 메르스
  • 세월호
  • 원전사고
  • 2016리오올림픽
  • 2018평창올림픽
  • 코로나19
  • 2020도쿄올림픽
  • 게시판찾기
  • 오유인페이지
    개인차단 상태
    Naissance님의
    개인페이지입니다
    가입 : 11-09-16
    방문 : 695회
    닉네임변경 이력
    회원차단
    회원차단해제
    게시물ID : programmer_12938
    작성자 : Naissance
    추천 : 2
    조회수 : 473
    IP : 222.232.***.169
    댓글 : 1개
    등록시간 : 2015/08/25 08:40:21
    http://todayhumor.com/?programmer_12938 모바일
    파이썬 연습
    옵션
    • 창작글
    <div><b>import random</b></div> <div><b>import math</b></div> <div><b><br></b></div> <div><b>MaxLevel=100</b></div> <div><b><br></b></div> <div><b># Defining Arrays and Dictionaries...</b></div> <div><b><br></b></div> <div><b>thingsToDo={</b></div> <div><b>"1":"Go to the field to hunt monsters",</b></div> <div><b>"2":"Get some rest"</b></div> <div><b>}</b></div> <div><b><br></b></div> <div><b>levelHP={}</b></div> <div><b>for i in range(1,MaxLevel+1):</b></div> <div><b>    levelHP[str(i)]=100+i*20</b></div> <div><b><br></b></div> <div><b>levelMP={}</b></div> <div><b>for i in range(1,MaxLevel+1):</b></div> <div><b>    levelMP[str(i)]=40+10*i</b></div> <div><b><br></b></div> <div><b>requestedEXP={}</b></div> <div><b>for i in range(2,MaxLevel):</b></div> <div><b>    requestedEXP[str(i)]=20+10*i</b></div> <div><b><br></b></div> <div><b># Defining Classes...</b></div> <div><b><br></b></div> <div><b>class Entity(object):</b></div> <div><b>    day=1</b></div> <div><b>    def __init__(self,name):</b></div> <div><b>        self.name=name</b></div> <div><b>        self.level=1</b></div> <div><b>        self.HP=100</b></div> <div><b>        self.MP=50</b></div> <div><b>        self.EXP=0</b></div> <div><b>    def setHP(self, HP):</b></div> <div><b>        self.HP=HP</b></div> <div><b>    def setMP(self, MP):</b></div> <div><b>        self.MP=MP</b></div> <div><b>    def addHP(self, amountHP):</b></div> <div><b>        self.HP+=amountHP</b></div> <div><b>        if amountHP<=0:</b></div> <div><b>            print("HP decreased by %d!!"%amountHP)</b></div> <div><b>        else:</b></div> <div><b>            print("HP increased by %d!!"%amountHP)</b></div> <div><b>    def addMP(self, amountMP):</b></div> <div><b>        self.MP+=amountMP</b></div> <div><b>        if amountMP<=0:</b></div> <div><b>            print("MP decreased by %d!!"%amountMP)</b></div> <div><b>        else:</b></div> <div><b>            print("MP increased by %d!!"%amountMP)</b></div> <div><b>    def addEXP(self, amountEXP):</b></div> <div><b>        self.EXP+=amountEXP</b></div> <div><b>        if amountEXP<=0:</b></div> <div><b>            print("EXP decreased by %d!!"%amountEXP)</b></div> <div><b>        else:</b></div> <div><b>            print("EXP increased by %d!!"%amountEXP)</b></div> <div><b><br></b></div> <div><b># Defining functions...</b></div> <div><b><br></b></div> <div><b>def beginningMent():</b></div> <div><b>    print("-- Custom RPG V 1.0 --")</b></div> <div><b>    print("First, We need to make your own character")</b></div> <div><b><br></b></div> <div><b>def makingCharacter():</b></div> <div><b>    print("Input your character's name")</b></div> <div><b>    userName=input("Type here... =")</b></div> <div><b>    print("Your name is %s. Let the game begin..."%(userName))</b></div> <div><b>    print("A Character instance has been created...")</b></div> <div><b>    return Entity(userName)</b></div> <div><b><br></b></div> <div><b>def printDay(player):</b></div> <div><b>    print("   ")</b></div> <div><b>    print("-- Day %d --"%player.day)</b></div> <div><b><br></b></div> <div><b>def printStatus(player):</b></div> <div><b>    print("LEVEL : %d"%player.level)</b></div> <div><b>    print("HP : %d"%player.HP)</b></div> <div><b>    print("MP : %d"%player.MP)</b></div> <div><b>    print("EXP : %d out of %d"%(player.EXP, requestedEXP[str(player.level+1)]))</b></div> <div><b><br></b></div> <div><b>def chooseSelection():</b></div> <div><b>    for key, value in thingsToDo.items():</b></div> <div><b>        print(key,value)</b></div> <div><b>    userInput=input("Input the proper code")</b></div> <div><b>    print("You've selected %s."%(userInput))</b></div> <div><b>    for key, value in thingsToDo.items():</b></div> <div><b>        if userInput==key:</b></div> <div><b>            return key</b></div> <div><b>    print("You've selected a wrong code")</b></div> <div><b>    print("Try again")</b></div> <div><b>    chooseSelection()</b></div> <div><b><br></b></div> <div><b>def branch(code, player):</b></div> <div><b>    if code=="1":</b></div> <div><b>        hunt(player)</b></div> <div><b>    elif code=="2":</b></div> <div><b>        rest(player)</b></div> <div><b><br></b></div> <div><b>def getFullHP(player):</b></div> <div><b>    stringifiedLevel=str(player.level)</b></div> <div><b>    amountOfFullHP=levelHP[stringifiedLevel]</b></div> <div><b>    player.setHP(amountOfFullHP)</b></div> <div><b><br></b></div> <div><b>def getFullMP(player):</b></div> <div><b>    stringifiedLevel=str(player.level)</b></div> <div><b>    amountOfFullMP=levelMP[stringifiedLevel]</b></div> <div><b>    player.setMP(amountOfFullMP)</b></div> <div><b><br></b></div> <div><b>def hunt(player):</b></div> <div><b>    print("%s is going to the field to hunt some monsters"%player.name)</b></div> <div><b>    for encounter in range(1,random.randint(3,5)):</b></div> <div><b>        multiplyer=1</b></div> <div><b>        if player.HP<10:</b></div> <div><b>            print("Your HP is too low!")</b></div> <div><b>            print("You are going home")</b></div> <div><b>            player.day+=1</b></div> <div><b>            return</b></div> <div><b>        if player.MP<10:</b></div> <div><b>            print("Your MP is too low!")</b></div> <div><b>            print("Your power has been decreased!")</b></div> <div><b>            multiplyer=0.8</b></div> <div><b>        print("-- Encounter %d --"%encounter)</b></div> <div><b>        print("A group of wild rats have appeared!!")</b></div> <div><b>        winRate=random.randint(0,math.floor(5*multiplyer))</b></div> <div><b>        if winRate==0:</b></div> <div><b>            print("You have beaten by the wild rats!! What a shame!")</b></div> <div><b>            player.addHP(random.randint(-30,-10))</b></div> <div><b>            player.addMP(random.randint(-10,-5))</b></div> <div><b>            break</b></div> <div><b>        else:</b></div> <div><b>            print("You have defeated the wild rats!! Congrats!")</b></div> <div><b>            player.addHP(random.randint(-30,-10))</b></div> <div><b>            player.addMP(random.randint(-10,-5))</b></div> <div><b>            player.addEXP(random.randint(10,20))</b></div> <div><b>    print("The hunting has finished!!")</b></div> <div><b>    player.day+=1</b></div> <div><b><br></b></div> <div><b>def rest(player):</b></div> <div><b>    print("You got some rest!!")</b></div> <div><b>    print("Your HP restored!")</b></div> <div><b>    print("Your MP restored!")</b></div> <div><b>    getFullHP(player)</b></div> <div><b>    getFullMP(player)</b></div> <div><b>    player.day+=1</b></div> <div><b><br></b></div> <div><b>def checkLevel(player):</b></div> <div><b>    if player.EXP>=requestedEXP[str(player.level+1)]:</b></div> <div><b>        print("You've leveled up!!")</b></div> <div><b>        print("from %d to %d"%(player.level,player.level+1))</b></div> <div><b>        player.level+=1</b></div> <div><b>        player.EXP=0</b></div> <div><b><br></b></div> <div><b>def checkPlayerStatus(player):</b></div> <div><b>    if player.HP<0:</b></div> <div><b>        print("You have fatigued!!")</b></div> <div><b>        print("You can't do anything today!")</b></div> <div><b>        rest(player)</b></div> <div><b><br></b></div> <div><b># Main part...</b></div> <div><b><br></b></div> <div><b>beginningMent()</b></div> <div><b>player=makingCharacter()</b></div> <div><b><br></b></div> <div><b>while(True):</b></div> <div><b>    printDay(player)</b></div> <div><b>    checkLevel(player)</b></div> <div><b>    checkPlayerStatus(player)</b></div> <div><b>    printStatus(player)</b></div> <div><b>    selection=chooseSelection()</b></div> <div><b>    branch(selection, player)</b></div> <div><br></div>

    이 게시물을 추천한 분들의 목록입니다.
    [1] 2015/08/25 09:10:32  210.95.***.36  구차니  168644
    [2] 2016/01/23 07:56:20  211.36.***.108  음모파헤치기  539263
    푸르딩딩:추천수 3이상 댓글은 배경색이 바뀝니다.
    (단,비공감수가 추천수의 1/3 초과시 해당없음)

    죄송합니다. 댓글 작성은 회원만 가능합니다.

    번호 제 목 이름 날짜 조회 추천
    49
    Mirror's Edge - Still Alive [9] 펌글 Naissance 15/08/26 16:35 101 3
    48
    Portal 2 - If I were a core [2] 펌글 Naissance 15/08/26 16:34 40 0
    47
    KT Tunstall - Suddenly I see 펌글 Naissance 15/08/26 16:22 19 5
    46
    베지마이트 [3] 창작글 Naissance 15/08/26 16:14 43 0
    45
    Dear Cloud - Remember [1] 펌글 Naissance 15/08/25 21:41 21 4
    44
    디지털 오션에서 프로모션 쿠폰 나눠주고 있네요 [4] 창작글 Naissance 15/08/25 21:02 31 2
    43
    Kat DeLuna - Calling YOU [1] 펌글 Naissance 15/08/25 10:19 11 2
    파이썬 연습 [1] 창작글 Naissance 15/08/25 08:40 43 2
    41
    David Guetta - Play Hard 펌글 Naissance 15/08/24 21:48 17 3
    40
    대화할 때 제스처를 못하겠어요 [2] 창작글 Naissance 15/08/24 20:56 31 0
    39
    한국여자들이 생각하는 가장 이상적인 한국여자 [6] 펌글 Naissance 15/08/24 18:09 409 2
    38
    Zedd - Clarity 펌글 Naissance 15/08/24 16:49 16 4
    37
    Madeon - Pay no mind [1] 펌글 Naissance 15/08/24 12:55 22 5
    36
    에이즈에 걸린 10대가 레스토랑에서 식사를 하고 있다면 WWYD? [2] 펌글 Naissance 15/08/21 15:53 68 0
    35
    폭스 뉴스와 NBC 기자의 싸움 펌글 Naissance 15/08/20 17:08 50 0
    34
    Train - 50 Ways to say Goodbye [3] 펌글 Naissance 15/08/19 15:58 19 5
    33
    겨울왕국 검열판 [2] 펌글 Naissance 15/08/19 10:21 75 0
    32
    마이 롯데 텔레비전 [1] 펌글 Naissance 15/08/13 10:09 118 4
    31
    60초만에 보는 진화의 과정 [25] 펌글 Naissance 15/08/13 09:50 83 11
    30
    메르카토르 지도의 왜곡 [4] 펌글 Naissance 15/08/13 09:46 184 4
    29
    개인적으로 hwp같은 비표준 확장자는 사용을 자제해야 한다고 생각합니다. [11] 창작글 Naissance 15/08/12 13:18 142 4
    28
    굴림체 광고 창작글 Naissance 15/08/10 21:23 27 1
    27
    수도권지하철 4호선 노선도 영문번역 (뻘짓) [1] 창작글 Naissance 15/08/02 22:57 27 1
    26
    4개월만에 만난 어미개와 개새끼 [3] 펌글 Naissance 15/07/29 14:38 44 1
    25
    투블루 처녀작입니다. 창작글 Naissance 15/07/28 14:26 45 0
    24
    같이 알바하실 분 없나요... [8] Naissance 15/07/27 14:16 180 0
    23
    가까스로 위험을 피한 사람들 [5] Naissance 15/07/27 12:30 244 0
    22
    동양 청년들이 꿈을 잃는 이유 Naissance 15/07/14 18:46 36 0
    21
    블렌더로 구리 와이어 만들어봤어요 [3] 창작글 Naissance 15/06/27 17:42 20 11
    20
    블렌더로 어항 속에 빠진 목도리 만들어봤어요 창작글 Naissance 15/06/27 14:23 18 5
    [1] [2] [3]
    단축키 운영진에게 바란다(삭제요청/제안) 운영게 게시판신청 자료창고 보류 개인정보취급방침 청소년보호정책 모바일홈