모바일 오유 바로가기
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도쿄올림픽
  • 게시판찾기
  • 오유인페이지
    개인차단 상태
    허허엌님의
    개인페이지입니다
    가입 : 11-07-10
    방문 : 772회
    닉네임변경 이력
    회원차단
    회원차단해제
    게시물ID : jisik_121052
    작성자 : 허허54752;
    추천 : 0
    조회수 : 260
    IP : 99.225.***.113
    댓글 : 0개
    등록시간 : 2012/03/08 15:10:56
    http://todayhumor.com/?jisik_121052 모바일
    파이썬 잘하는 횽님들 좀 도와줘요
    파이썬 프로그래밍 숙제인데...
    잘 하고 있는지 모르겠네요 ㅎㅎㅎ


    일단 이게 데이타 파일이에요.
    4
    5

    2 3 4 1 1
    5 4 2 5 4
    4 5 3 1 3
    1 1 1 5 5
    data. txt


    1)write a 코드 called open_file_forassignment2 that takes in the name of 
    the input file and opens it. the file is returned back from the 코드
    여기서 일단 파일을 열고, 오픈을 한다음. 그냥 리턴을 해야되는지, 아니면 스트립을 해야 하는지
    모르겠네요..


    def open_file_for_assignment2():
    data=open('data.txt','r')
    for line in data:
    line = line.strip()
    print len(line)

    2) write a 코드 called 'read_user_movie_matrix' that takes in as input the 
    file that is opened from step 1 above and returns back a nested list which is 
    the user_movie_matrix. this 코드 must read the data from the input file.
    여기서 요점은 "nested list" 로 리턴이 되야 한다는건데..
    내가 맞게 했는지 모르겠네요

    def read_user_movie_matrix(fileObject):
    nestedList=[]
    numberOfUsers=int(fileObject.readline())
    numberOfMovies=int(fileObject.readline())
    blankLine=fileObject.readline()
    for singleRow in fileObject:
    removeWhiteSpace=singleRow.strip()
    row_in_list=removeWhiteSpace.split()
    nestedList.append(row_in_list)
    return nestedList

    3) write a 코드 called 'calculate_similarity_score' and returns back the 
    similarity score btw pair of users. (you are free to choose whatever you like as 
    input to the 코드)

    similarity score 는 1/(1+ 유저1,유저2) 의 유클라디언 거리 
    즉 
    루트 ((x2-x1)제곱 + (y2-y2)제곱 )
    그래서 helper 코드 을 만들어 봤어요

    def distance_score(user1,user2):
    user1=file.readline(3) 요기서 유저1이랑 유저2 얘네들을 define 해줘야 되는데..
    user2=file.readline(4) 어떻게 하는지 잘 모르겠네요..
    distance = sqrt((user1[1]-user2[1])**2+(user1[2]-user2[2])**2))
    return distance
    def calculate_similarty_score(user1,user2):
    user1=file.readline(3) 위에랑 마찬가지로..ㅠ_ㅠ 어찌 define 을 해야 하는지...
    user2=file.readline(4)
    similarity_score =1.0/(1+distance_score(user1,user2))
    return similarity_score

    4) write a 코드called 'populate_user_user_matrix' that creates a 
    user_user_matrix and returns it. (you are free to choose whatever you like as 
    input to the 코드)
    이거는 수열을 만들어라 하는데.. 이렇게 만들면 되는건지... 사실 이부분부터 되게 막힘..ㅠ_ㅠ
    def populate_user_matrix(user1,user2):

    matrix1=()
    matrix2=()
    for num1 in user1:
    append.int(matrix1)
    for num2 in user2:
    append.int(matrix2)
    return matrix2
    return matrix1

    5) write a 코드 called 'print_user_user_matrix' that prints the 
    user_user_matrix on the screen (you are free to choose whatever you like as 
    input to the 코드)
    이건 4번이랑 뭐가 틀린지 말 모르겠음.. 이것도 유저-유저 간의 수열을 작성하라는데..
    프린트를 쓰는게 다인지...
    def print_user_user_matrix(user1,user2):
    user1=file.readline(3)
    user2=file.readline(4)
    print matrix1
    print matrix2

    6) write a 코드 called 'most_similar_pair_of_users' that prints the most smilar
    pair of users on the screen (you are free to choose whatever you like as 
    input to the 코드)
    이거는 유저간의 취향이 가장 비슷한 즉 위에 3번의 similarity score 가 가장 작은 페어를 찾는건데
    이렇게 여러가지의 경우의 수가 나올 수 있는데 .. 이건 맞게 하는게 맞는지...
    #ie) 1,2 or 1,3, or 1,4 or 1,5, or 2,3, or 2,4, or 2,5, or 3,4, or 3,5, or 4,5,
    def most_similar_pair_of_users(users): 
    users=read_user_movie_matrix()
    for num in range(len(users)):
    calculate_similarity_score(num)
    return min(calculate_similarity_score(num))

    7) write a 코드 called 'most_dissimilar_pair_of_users' that prints the most
    dissimilar pair on the screen(you are free to choose whatever you like as 
    input to the 코드)
    이건 6번과 같이...가장 거리가 먼 유저 콤비를 찾으면 되는건데..
    그래서 6번이랑 똑같이 하고
    def most_similar_pair_of_users(users): 
    users=read_user_movie_matrix()
    for num in range(len(users)):
    calculate_similarity_score(num)
    return max(calculate_similarity_score(num))
    요기 맥시멈으로 했음.

    8) write a 코드 called 'start_assignment_2' which will be what the TA will 
    call to run your assignment. this wunction will ask the user to enter the name 
    of the input file that needs to be red (use the inbuilt 코드 raw_input) 
    ("please enter the name of the input file?") it is responsible to call the above
    코드 as necessary so that your output gets printed.'''
    이거는 이제 우리 조교가 우리 과제를 실행을 시킬때,
    파일 이름을 물어보는거임
    def start_assignemnt_2():
    raw_input("Please enter the file name")

    아무튼 여기까지였습니다.
    좀 도와주면 매우 매우 감사하겠어요!!

    이 게시물을 추천한 분들의 목록입니다.
    푸르딩딩:추천수 3이상 댓글은 배경색이 바뀝니다.
    (단,비공감수가 추천수의 1/3 초과시 해당없음)

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

    번호 제 목 이름 날짜 조회 추천
    18
    노트북 비교좀 해주세요! 여러분의 선택은?? [7] 허허엌 15/01/02 19:14 50 0
    17
    안녕하세요 램 관련 질문 드립니다. [7] 허허엌 14/12/03 19:42 52 0
    16
    안녕하세요, 보드 질문 있습니다. [15] 허허엌 14/11/26 06:38 68 0
    15
    CPU 질문있습니다! [6] 허허엌 14/11/26 04:36 63 0
    14
    (다시한번 본삭금) 컴터 조립 견적좀 내주세요! [6] 허허엌 14/11/23 19:41 51 0
    13
    SSHD VS SSD [11] 허허엌 14/11/23 16:55 160 0
    12
    (본삭금)컴터 업글을 하고 싶은데요..ㅠ 추천좀 해주세요 [3] 허허54752; 14/11/23 05:51 42 0
    11
    파이썬 프로그래밍 언어 잘하는 횽들! 도와주면 여친 생겨요!! 허허54752; 12/04/07 00:00 28 0
    10
    파이썬 프로그래밍 언어 잘하는 횽들! 도와주면 여친 생겨요!! 허허54752; 12/04/06 23:59 31 0
    9
    파이썬 프로그래밍 잘하는 횽들! 도와주면 여친 생겨요!! 허허54752; 12/04/06 09:31 50 0
    8
    파이썬 프로그래밍 언어 잘하는 횽들! 도와주면 여친 생겨요!! 허허54752; 12/04/06 09:30 46 0
    파이썬 잘하는 횽님들 좀 도와줘요 허허54752; 12/03/08 15:10 30 0
    6
    파이썬 잘 하는 횽님들 좀 도와줘요 허허54752; 12/03/08 15:10 62 0
    5
    이분 이름이 어떻게 되시는지 좀 가르쳐 주세요!! [1] 허허54752; 11/10/10 09:04 136 0
    4
    착신아리 벨소리좀 찾아주세요 컴맹임 11/07/30 01:32 28 0
    3
    횽님들!! 착신아리 벨소리가 너무 가지고싶어요! [4] 컴맹임 11/07/30 00:24 358 0
    2
    횽들아!! 착신아리 벨소리가 너무 가지고 싶은데... [2] 컴맹임 11/07/30 00:07 72 0
    1
    Reminisce횽님이랑 파이선 고수님들 도와주세요!!! [16] 컴맹임 11/07/11 02:55 119 0
    [1]
    단축키 운영진에게 바란다(삭제요청/제안) 운영게 게시판신청 자료창고 보류 개인정보취급방침 청소년보호정책 모바일홈