inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

이야기를 나눠요

174만명의 커뮤니티!! 함께 토론해봐요.

성적처리프로그램 만들어봤어요~

파이썬(Python) 기초부터 실무까지 part.2

from statistics import mean from copy import deepcopy def main() : score = [[ 100 , 100 , 100 ], [ 20 , 20 , 20 ], [ 30 , 30 , 30 ], [ 40 , 40 , 40 ], [ 50 , 50 , 50 ]] score = make_tablelist(score) print_table(score) print () def make_tablelist(li1): kuksum = 0 engsum = 0 matsum = 0 temp = deepcopy(li1) for i in range ( 0 , len (li1)): temp[i].insert( 0 , i + 1 ) temp[i].append( sum (li1[i])) temp[i].append( float (mean(li1[i]))) kuksum += temp[i][ 1 ] engsum += temp[i][ 2 ] matsum += temp[i][ 3 ] temp.insert( 0 , [ ' 번호 ' , ' 국어 ' , ' 영어 ' , ' 수학 ' , ' 총점 ' , ' 평균 ' ]) temp.append([ ' 총점 ' , kuksum, engsum, matsum, sum ([kuksum, engsum, matsum]), mean([kuksum, engsum, matsum])]) return temp def print_table(pli) : for i in range ( len (pli)) : for j in range ( len (pli[i])) : if j == len (pli[i])- 1 : print ( "{:>6}" .format(pli[i][j])) else : print ( "{:>6} \t " .format(pli[i][j]), end = '' ) if i == 0 or i == len (pli) - 2 : print ( "-" * 50 ) if __name__== "__main__" : main() ------------------------------------------------------------------- 응용해서 나중에 성적을 순서대로나 개별로 입력받아서 등록할 수 있는 기능등도 추가할 수 있을 것 같아요~ 강의 감사합니다~

g9191hc 댓글 1 좋아요 0 조회수 635

0,1 체크보드 만들어봤습니다

파이썬(Python) 기초부터 실무까지 part.2

# 0 과 1 이 반복되는 10x10 체크보드형상 2 차원리스트 만들기 ckbd = [([ 0 ]+[ 1 ])* 5 for x in range ( 5 )] for i in range ( 1 , 10 , 2 ) : ckbd.insert(i,([ 1 ]+[ 0 ])* 5 ) for x in range ( 10 ) : print (ckbd[x], sep = ' \n ' )

g9191hc 댓글 0 좋아요 0 조회수 636

선택정렬 만들어봤어요~

파이썬(Python) 기초부터 실무까지 part.2

def select_sort(li1) : for i in range ( len (li1)) : for j in range (i+ 1 , len (li1)) : if li1[i] > li1[j] : li1[i], li1[j] = li1[j], li1[i] odd_num = [ 7 , 15 , 9 , 13 , 71 , 3 , 1 ] print ( " 정렬 전 :" ,odd_num) select_sort(odd_num) print ( " 정렬 후 :" ,odd_num, " \n " )

g9191hc 댓글 0 좋아요 0 조회수 312

친구리스트 코드 만들어봤어요~

파이썬(Python) 기초부터 실무까지 part.2

def main() : show_menu() print ( " 종료되었습니다 ." ) def show_menu() : frdlist = [] menulist = [ "1" , "2" , "3" , "4" , "9" ] menu= '' while menu != '9' : print ( "-" * 20 ) print ( "1. 친구리스트 출력 " ) print ( "2. 친구추가 " ) print ( "3 친구삭제 " ) print ( "4. 이름변경 " ) print ( "9. 종료 " ) menu = input ( " 메뉴를 선택하시오 : " ) if menu not in menulist : print ( "-" * 20 ) print ( " 잘못입력하셨습니다 ." ) else : match menu : case '1' : print_friends(frdlist) case '2' : append_friend(frdlist) case '3' : delete_friend(frdlist) case '4' : change_name(frdlist) print ( "-" * 20 ) def print_friends(list) : print ( "-" * 20 ) if not len (list) : print ( " 저장되어 있는 친구가 없습니다 ." ) else : print ( " 저장되어 있는 친구는 " ,list, " 입니다 ." ) def append_friend(list) : print ( "-" * 20 ) frdname = input ( " 이름을 입력하시오 : " ) list.append(frdname) print ( "'{}' 이름이 친구리스트에 추가되었습니다 ." .format(frdname)) def delete_friend(list) : print ( "-" * 20 ) frdname = "" while True : print (list) frdname = input ( " 위 리스트 중 삭제하고 싶은 이름을 입력해주세요 : " ) if frdname in list : break else : print ( " 리스트 중에 없는 이름입니다 ." ) print ( "-" * 20 ) list.remove(frdname) print ( "'{}' 이름이 삭제되었습니다 ." .format(frdname)) def change_name(list) : print ( "-" * 20 ) frdname = "" while True : print (list) frdname = input ( " 위 리스트 중 바꾸고 싶은 이름을 입력해주세요 : " ) if frdname in list: break else : print ( " 리스트 중에 없는 이름입니다 ." ) print ( "-" * 20 ) yesorno = [ ' 네 ' , ' 아니오 ' ] flag = True while flag: cngname = input ( " 어떤 이름으로 변경할까요 ?: " ) while True : print ( " 변경하고 싶은 이름이 '{}' " .format(cngname), end = '' ) confirm = input ( " 맞나요 ?( 네 / 아니오 ): " ) if confirm not in yesorno : print ( "' 네 / 아니오 ' 로만 입력해주세요 ." ) else : if confirm == ' 네 ' : print ( " 이름이 '{}' 에서 '{}' 로 변경되었습니다 ." .format(frdname, cngname)) ind = list.index(frdname) list[ind] = cngname flag = False break if __name__== '__main__' : main()

g9191hc 댓글 0 좋아요 1 조회수 588

리스트 어프리헨션으로 구구단 리스트를 만들어봤어요~

파이썬(Python) 기초부터 실무까지 part.2

list1 = [x for x in range ( 2 , 10 )] list2 = [ " x " ] list3 = [y for y in range ( 1 , 10 )] list4 = [ " = " ] list5 = [ str (x)+a+ str (y)+b+ str (x*y) for x in list1 for a in list2 for y in list3 for b in list4] print (list5, " \n ")

g9191hc 댓글 0 좋아요 0 조회수 301

스프링 데이터 접근기술은 언제 나오나요??

실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발

스프링 데이터베이스 접근 기술에 대해 깊이 공부하고싶은데 언제 강의가 나오는지 알 수 있을까요?

조인태 댓글 3 좋아요 0 조회수 372

변수 -1

- 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요 보통 int result = -1로 변수로 두던데 왜 int result=0으로 안하고 -1로 하나요??

rnentkdals 댓글 0 좋아요 0 조회수 399

-1 변수

- 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요 보통 변수에서 int result = -1 로 두던데, 왜 0으로 안두고 -1로 두는건가여??

rnentkdals 댓글 0 좋아요 0 조회수 355

firebase v9 전체소스 수정 코드

따라하며 배우는 리액트, 파이어베이스 - 채팅 어플리케이션 만들기[2023.12 리뉴얼]

- 아래는 전체 소스 코드 입니다. - 올려주신 v9 소스코드 보고 현 강의 내용에 맞게 수정 했습니다. import React , { Component } from 'react' ; import { FaRegSmileWink , FaPlus } from 'react-icons/fa' ; import Modal from 'react-bootstrap/Modal' ; import Button from 'react-bootstrap/Button' ; import Form from 'react-bootstrap/Form' ; // import { } from 'react-icons/fa'; import { connect } from 'react-redux' ; import { getDatabase , ref , onChildAdded , onValue , push , child , update , off } from "firebase/database" ; export class ChatRooms extends Component { state = { show : false , name : "" , description : "" , chatRoomsRef : ref ( getDatabase (), "chatRooms" ), } handleClose = () => this . setState ({ show : false }); handleShow = () => this . setState ({ show : true }); hanldeSubmit = ( e ) => { e . preventDefault (); const { name , description } = this . state ; if ( this . isFormValid ( name , description )){ this . addChatRomm (); } } addChatRomm = async () => { const key = push ( this . state . chatRoomsRef ). key ; const { name , description } = this . state ; const { user } = this . props ; const newChatRoom = { id : key , name : name , description : description , createdBy : { name : user . displayName , image : user . photoURL } } try { await update ( child ( this . state . chatRoomsRef , key ), newChatRoom ) this . setState ({ name : "" , description : "" , show : false }) console . log ( "chatRR" , this . state . chatRoomsRef ); console . log ( "newC" , newChatRoom ); console . log ( "key" , key ); } catch ( error ){ console . log ( error ); } } isFormValid = ( name , description ) => name && description ; render () { return < div > < div style = { { position : 'relative' , width : '100%' , display : 'flex' , alignItems : 'center' } } > < FaRegSmileWink style = { { marginRight : 3 } } /> CHAT ROOMS (1) < FaPlus onClick = { this . handleShow } style = { { position : 'absolute' , right : 0 , cursor : 'pointer' } } /> </ div > { /*ADD CHAT ROOM MODAL*/ } < Modal show = { this . state . show } onHide = { this . handleClose } > < Modal.Header closeButton > < Modal.Title > Create a Chat Room </ Modal.Title > </ Modal.Header > < Modal.Body > < Form onSubmit = { this . hanldeSubmit } > < Form.Group className = "mb-3" controlId = "formBasicEmail" > < Form.Label > 방 이름 </ Form.Label > < Form.Control onChange = { ( e ) => this . setState ({ name : e . target . value }) } type = "text" placeholder = "Enter a ChatRoom Name" /> </ Form.Group > < Form.Group className = "mb-3" controlId = "formBasicPassword" > < Form.Label > 방 설명 </ Form.Label > < Form.Control onChange = { ( e ) => this . setState ({ description : e . target . value }) } type = "text" placeholder = "Enter a ChatRoom Description" /> </ Form.Group > </ Form > </ Modal.Body > < Modal.Footer > < Button variant = "secondary" onClick = { this . handleClose } > 취소 </ Button > < Button variant = "primary" onClick = { this . hanldeSubmit } > 방 생성 </ Button > </ Modal.Footer > </ Modal > </ div > ; } } const mapStateToProps = state => { return { user : state . user . currentUser } } export default connect ( mapStateToProps ) ( ChatRooms );

황경훈 댓글 0 좋아요 0 조회수 382

downloadURL

따라하며 배우는 리액트, 파이어베이스 - 채팅 어플리케이션 만들기[2023.12 리뉴얼]

일단 파이어베이스 문제인지 강의 내용에 나와있는 ref.getdownloadURL() 형태로는 불러올 수 가 없습니다. 그렇기 때문에 import 쪽에 getDownloadURL을 추가해주시고 import { getStorage , ref , uploadBytes , getDownloadURL } from "firebase/storage" ; 이후에 let downloadURL = await getDownloadURL ( ref ( storage , `user_image/ ${ user . uid } ` )); 위와 같이 해주면 되겠습니다. 또한 403 에러가 나오신다면 규칙 문제이니 allow read, write: if true; 로 바꿔주시면 되겠습니다 참고 문헌 : https://stackoverflow.com/questions/50432995/firebase-cloud-storage-permission-denied-could-not-perform-this-operation-fire https://firebase.google.com/docs/storage/web/download-files#web-version-9_1

황경훈 댓글 1 좋아요 0 조회수 279

수고하셨습니다!

3D 게임 디자이너에게 배우는 Zbrush 2020 기초와 활용

너무 알찬 강의해 주셔서 너무 감사합니다 강사님 덕분에 지브러쉬에 쉽게 접근할 수 있게 되었어요 고생 많으셨습니다!!

송창민 댓글 0 좋아요 0 조회수 265

선생님 질문 있습니다

[C++과 언리얼로 만드는 MMORPG 게임 개발 시리즈] Part2: 게임 수학과 DirectX12

- 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 선생님 답변 듣고 멘탈을 추스리고 일단 강의를 듣고 있는 중에 궁금증이 생겨서 질문 남겨요! 선생님 강의 듣고, 책으로도 공부하려고 하고 있습니다(배송중이여서 책은 아직 못봤습니다) 최종 결과물로는 directX로 게임을 제작할텐데 그때도 이렇게 복사 붙여넣기의 연속인가요??? c++ 공부할 떄 처럼 따라치는게 아니라 복사 붙여넣기만 하다보니 공부가 되는건지에 대한 의문이 해결이 안되니깐 하루에 공부를 7-8시간씩해도 시간을 버리는 느낌.,.?도 들고 너무 답답합니다.. (독학으로 하고 있어서,, 선생님이 자주 말씀하시는 헤딩을 하고 있는 것 같은데,,ㅠㅠ 답답하네요) 먼저 이 길을 지나가진 선생님으로서... 이 답답함 해결해주실수있을까요..? 항상 친절하게 답변해주셔서 감사합니다!!

장재범 댓글 1 좋아요 0 조회수 233

swr 서버 질문

Slack 클론 코딩[실시간 채팅 with React]

안녕하세요 저는 현재 백엔드쪽에서 토이프로젝트를 하고 있습니다. 프론트는 잘 모르지만 구현이 필요해서 제가 하게 되었습니다 제로초님 무료 react 강의를 듣고 sleact 구매하게 되었는데요 토이프로젝트의 서버가 springboot 여서 혹시 swr과 호환이 되는지 궁금합니다

김노아 댓글 1 좋아요 1 조회수 359

ref is not a function 해결

따라하며 배우는 리액트, 파이어베이스 - 채팅 어플리케이션 만들기[2023.12 리뉴얼]

파이어 베이스 업데이트가 원인인지는 잘 모르겠으나. 강의 내용대로 하면 몇 가지 오류 사항이 있을 겁니다. 일단 mime-types 도 에러가 나서 저는 따로 file.type을 받아와서 처리했습니다. const handleUploadImage = async ( event ) => { const file = event . target . files [ 0 ]; const metadata = { contentType : file . type }; //스토리지에 파일 저장하기 console . log ( 'file' , file ); console . log ( 'meta' , metadata ); 일단 제가 해결 했던 방법은. 아래와 같이 firebase/storeage를 import 해줍니다. import { getStorage , ref , uploadBytes } from "firebase/storage" ; 그 이후에 getStorages() 와, storageRef 부분을 선언해줍니다. const storage = getStorage (); const storageRef = ref ( storage , `user_image/ ${ user . uid } ` ); try { // 'file' comes from the Blob or File API const uploadTask = uploadBytes ( storageRef , file , metadata ); 이후엔 uploadBytes를 이용해서 인자값으로 저렇게 넣어주면 일단 데이터는 들어갈텐데 만약 403 에러가 나온다면 storage - Rules 에서 allow read,write: if request.auth != null; 로 바꿔주면 해결 될겁니다. 참고 문헌 : https://firebase.google.com/docs/storage/web/upload-files https://stackoverflow.com/questions/38671444/user-does-not-have-permission-to-access-this-object-firebase-storage-android 전체 소스 코드 import React ,{ useRef } from 'react' ; import { GiBroadsword } from 'react-icons/gi' ; import Dropdown from 'react-bootstrap/Dropdown' ; import Image from 'react-bootstrap/Image' ; import { useDispatch , useSelector } from 'react-redux' ; import firebase from '../../../firebase' ; import { getStorage , ref , uploadBytes } from "firebase/storage" ; // import mime from 'mime-types'; function UserPanel () { const user = useSelector ( state => state . user . currentUser ) const inputOpenImageRef = useRef (); console . log ( user ) const handleLogout = () => { firebase . auth (). signOut (); } const handleOpenImageRef = () => { inputOpenImageRef . current . click (); } const handleUploadImage = async ( event ) => { const file = event . target . files [ 0 ]; const metadata = { contentType : file . type }; //스토리지에 파일 저장하기 console . log ( 'file' , file ); console . log ( 'meta' , metadata ); const storage = getStorage (); const storageRef = ref ( storage , `user_image/ ${ user . uid } ` ); try { // 'file' comes from the Blob or File API const uploadTask = uploadBytes ( storageRef , file , metadata ); // let uploadTask = uploadBytesResumable(strRef(storage, `user_image/${user.uid}`), file, metadata) // console.log('upload',uploadTask); } catch ( error ){ console . log ( error ); } } return ( < div > { /* Logo */ } < h3 style = { { color : "white" } } > < GiBroadsword /> { "" } ChatApp </ h3 > < div style = { { display : "flex" , marginBottom : '1rem' } } > < Image src = { user && user . photoURL } style = { { width : '30p' , height : '30px' , marginTop : '3px' } } roundedCircle /> < input type = "file" accept = "image/jpeg, image/png" ref = { inputOpenImageRef } style = { { display : "none" } } onChange = { handleUploadImage } /> < Dropdown > < Dropdown.Toggle style = { { background : 'transparent' , boder : '0px' } } id = "dropdown-basic" > { user && user . displayName } </ Dropdown.Toggle > < Dropdown.Menu > < Dropdown.Item onClick = { handleOpenImageRef } > 프로필 사진 변경 </ Dropdown.Item > < Dropdown.Item onClick = { handleLogout } > 로그아웃 </ Dropdown.Item > </ Dropdown.Menu > </ Dropdown > </ div > </ div > ) } export default UserPanel ;

황경훈 댓글 1 좋아요 0 조회수 1043

윈도우 볼륨 마운팅에서 고생하시는 분들 ..

Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)

괜히 옆에 맥북 놔두고 윈도우로 따라해봤는데 힘든게 많네요 ㅋㅋㅋ 참고로 prometheus.yml 경로로 이동하셔서 (저는 아카이브해두려고 별도 폴더에 복사해왔어요) 이렇게 실행하시면 됩니다. docker run -d -p 9090:9090 \ --network ecommerce-network \ --name prometheus \ --mount "type=bind,source=$PWD\\prometheus.yml,target=/etc/prometheus/prometheus.yml" \ prom/prometheus

ello 댓글 1 좋아요 1 조회수 278

여기에 의존성도 같이 추가되어야 하는걸까요 ?

Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)

강의 따라가면서 만들어보고 있는데, DiscoveryService의 경우에는 별도로 의존성을 추가한 적이 없었던거 같습니다. 때문에 spring-cloud-starter-config 의존성을 추가해야 도커 동작이 의도한 대로 될 것 같은데 (실제로 설정 정보를 쓰는 부분은 없으니 이러나 저러나 결과는 같겠지만) 맞는걸까요 ? 짧은 시간에 몰아서 들으려고 하니 헷갈리네요 ㅎㅎ

ello 댓글 0 좋아요 0 조회수 255

Kotlin으로 하시는 분들은 memberRowMapper함수 이렇게 하시면 될 것 같습니다

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

- 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. private fun memberRowMapper (): RowMapper<Member>{ return RowMapper { rs:ResultSet , rowNum: Int -> Member(). apply { id = rs.getLong( "id" ) name = rs.getString( "name" ) } } }

spring.kim 댓글 1 좋아요 1 조회수 320

소수 구하는 문제 제맘대로 풀었습니다.

파이썬(Python) 기초부터 실무까지 part.1

# 입력받은 두 수 사이의 소수를 출력하는 프로그램 # 소수란 2 이상의 수 중에서 1 과 자신외에 자신을 나눌 수 없는 자연수를 말한다 . # 2 가 가장 작은 소수이므로 , 어떤 수를 반 (2) 으로 나눈것보다 큰 수로는 그 수를 나눌 수 없다 . # 따라서 어떤 수 n 이 있을 때 , 2 부터 n/2 까지의 수로 나눌 수 없으면 n 은 소수이다 . # 가능하면 적게 실행해야하므로 2 부터 n-1 까지 반복하지 않고 2 부터 n/2 까지 반복하는 것이 경제적이다 . def IsPriNum(num) : # 소수면 True, 소수가 아니면 False 반환하는 함수 for i in range ( 2 , round (num/ 2 )+ 1 ) : #2 부터 num/2 까지의 수 중 자신을 나눌 수 있는 (= 나누었을 때 나머지가 0 이되는 ) 수가 있을경우 소수가 아님 . if num > 3 and num%i == 0 : # 2(=3-1) 이상의 수 중 자신을 나누는 수가 있으면 IsPriNum 에서 False 반환 return False else : continue return True # 2 부터 num/2 까지의 수 중 자신을 나눌 수 있는 수가 없으면 IsPriNum 에서 True 반환 priNum = [] # 소수를 저장할 리스트 print ( " 입력하신 두 자연수를 포함한 사이의 자연수 중 소수를 출력합니다 ." ) firstNumStr = input ( " 첫 번째 자연수를 입력해주세요 : " ) lastNumStr = input ( " 두 번째 자연수를 입력해주세요 : " ) # 입력된 값 중 0 이 있거나 숫자가 아닌 값이 있을경우 재입력 while firstNumStr== '0' or lastNumStr== '0' or not (firstNumStr.isnumeric()) or not (lastNumStr.isnumeric()): print ( " 잘못 입력 하셨습니다 . 1 이상의 자연수를 숫자로 입력 해 주세요 ." ) firstNumStr = input ( " 첫 번째 자연수를 입력해주세요 : " ) lastNumStr = input ( " 두 번째 자연수를 입력해주세요 : " ) # 문자열을 정수로 변환 firstNum = int (firstNumStr) lastNum = int (lastNumStr) # 두 수 중 작은수를 firstNum 에 , 큰 수를 lastNum 에 저장 if firstNum > lastNum : temp = firstNum firstNum = lastNum lastNum = temp # 소수를 소수리스트에 추가하고 해당소수 출력 for i in range (firstNum, lastNum+ 1 ) : if i == 1 : # 1 일경우 Pass continue elif IsPriNum(i) == True : # 소수로 확인되면 아래 문장 실행 priNum.append(i) # 소수를 소수리스트에 추가 print ( "{} 는 소수입니다 ." .format(i)) # 추가된 소수 출력 print ( "{} 부터 {} 까지의 자연수 중 소수는 {} 개이며 , {} 입니다 ." .format(firstNum,lastNum, len (priNum),priNum))

g9191hc 댓글 0 좋아요 2 조회수 710

인기 태그

인프런 TOP Writers

주간 인기글