분류 전체보기
-
python, class, 인스턴스 생성 - 간단한 sns platform 코딩Python 2024. 7. 5. 19:44
파이썬, class를 사용하여 간단한 sns platform의 유저 정보를 받는 코딩 문제 저번 과제 피드백이 절차지향적으로 코드를 잘 짰다는 걸 보면.. 아마도.. 객체지향적으로는 단단함이 부족하다는 의미가 아닐까 싶었다.. 그래서 이번 과제가 class를 이용한 과제인만큼 객체지향적으로 코드를 짜보자고 다짐했다. 구현해야 할 조건은 아래와 같다.1. Member 클래스회원 이름 (name)회원 아이디 (username회원 비밀번호 (password)*회원 정보를 print해주는 display: 회원이름과 아이디만 보여주고 비밀번호는 보여줘서는 안됨 2. Post 클래스게시물 제목 (title)게시물 내용 (content)작성자 (author) : 회원의 username 이 저장되어야 함!3. 회원 ..
-
가위 바위 보 게임 코드 만들기Python 2024. 7. 4. 03:22
컴퓨터와 유저가 대결을 하는 가위바위보 게임이다. 가장 먼저 컴퓨터가 가위 바위 보 중 하나를 랜덤으로 뽑아야 해서 random 모듈을 import 했다.import randomprint("게임을 시작합니다.") 오늘 세션 이후 추가해준 코드win = 0lose = 0draw = 0option: ["가위", "바위", "보"] ["가위", "바위", "보"]가 반복적으로 여러번 나오니까 option list로 묶어줬고 마지막에 승, 패, 무승부 결과를 알려주기 위해 win, lose, draw 변수를 추가했다. get_computer_choice() : 컴퓨터가 선택한 가위 바위 보 함수로, 가위 바위 보 중 하나를 랜덤으로 뽑아야하므로 option을 인수로 받는 random.choice를 썼다. ..
-
github설치, repository 만들기, pycharm 연동, 파이썬 코드파일 올리기(pull, push..)Git 2024. 7. 3. 05:16
대환장 git파티... 업다운 게임, 가위바위보 게임 과제를 올릴 깃허브 리포지토리를 만들어야 했다. 깃을 쓰려면 아래 링크에 들어가서 각 pc 환경에 따라 git을 설치해주면 된다. 나도 여기까진 쉬웠다.https://git-scm.com/ Git git-scm.com 맥 터미널, 홈브루로 깃을 설치해주었다.$ brew install git 버전을 확인해보면 설치가 잘 됐는지 확인이 가능하다.$ git --versiongit version 2.45.2 github 홈페이지에 들어가서 계정을 만들고, 리포지토리를 만들고 하는 것까지는 뭐 괜찮았다.문제는 파이참과 깃허브를 연동하면서부터 시작됐다...어젯밤에 이어 오전 중에도 끙끙 앓고 있는데 영오매니저님이 오셔서 튜터님의 도움을 받아보면 좋겠다고 추천해주..
-
파이썬으로 업다운 게임 만들기Python 2024. 7. 2. 22:57
업다운 게임 코드 짜기 일단 컴퓨터가 유저가 맞출 숫자를 하나 랜덤으로 뽑아야 하니 random 모듈을 import 했다.게임이 시작될 때마다 1부터 100사이의 숫자 하나를 뽑는 건 계속 반복되는 일이니까 제일 먼저 함수로 만들어두고.import randomdef up_down_game(): return random.randint(1, 100) attempts는 시도 횟수 때문에 만들어줬는데, 처음에는 그냥 attempts = 0 이렇게만 했다. 근데 만들고보니 총 시도 횟수를 구해야 해서 나중에 total_attempts 리스트를 추가했다. 컴퓨터가 랜덤으로 숫자를 뽑는게 게임의 가장 첫번째 순서이기 때문에total_attempts = []print("UpDown 게임을 시작합니다.")while..
-
개발자가 포화라던데..thoughts💭 2024. 6. 30. 23:57
이번주가 진짜 어떻게 지나갔는지 모르겠다.사실 여러가지 고민때문에 정말 많이 망설였는데 강의듣고 공부하고 보니 너무 재밌었고 지금도 재밌다. 만열님께 감사하다ㅠㅠ5년 전, 10년 전에 선택했다면 얼마나 좋았을까 하는 부질없는 생각도 들고..아무튼 AI웹개발, 파이썬 기초, 심화를 듣고 업무 자동화 개발 강의를 들었다면 훨씬 수월했겠다 싶으면서도업무자동화 개발 과정을 들은 덕분에 지금 강의들이 조금은 더 수월하게 이해가 되는 것 같기도 하다. 이해가 안될 때마다 바보가 된 것 같아서 자괴감이 들고 다시 본업으로 돌아가야하나 싶었다.그 생각은 지금도 유효하긴 한데지금의 이유는, 온 힘을 다해 최선을 다했는데 그 끝에 있는 현실이 절망뿐이면 정말 감당이 안될 것 같기 때문이다. 코드 짜는것도 공부하는것도 너무..
-
파이썬 문법 심화Python 2024. 6. 30. 07:54
자주 사용되는 모듈 및 패턴 1. type()integer = 10float_ = 1.23string = "hello world!!"list_ = [1, 2, 3]tuple_ = (1, 2, 3)set_ = {1, 2, 3}dictionary = {"key": "value"}boolean = Trueprint(type(integer)) # print(type(float_)) # print(type(string)) # print(type(list_)) # print(type(tuple_)) # print(type(set_)) # print(type(dictionary)) # print(type(boolean)) # a = 1b = '1' 이럴 경우 숫자 1인지 문자 1인지 알 수 없는데 이때 type(..
-
파이썬 문법 기초Python 2024. 6. 28. 21:00
반복문, 조건문 활용 예제 1people = [ {'name': 'bob', 'age': 20}, {'name': 'carry', 'age': 38}, {'name': 'john', 'age': 7}, {'name': 'smith', 'age': 17}, {'name': 'ben', 'age': 27}, {'name': 'bobby', 'age': 57}, {'name': 'red', 'age': 32}, {'name': 'queen', 'age': 25}]for i, person in enumerate(people): name = person['name'] age = person['age'] print(i, name, age) if i >..
-
Python, SQLite, SQLAlchemy, Database 조작Python 2024. 6. 27. 18:45
SQLite Python에는 기본적으로 SQLite가 내장되어 있으므로 별도 설치 없이 VScode에서 파일이름.db 형식으로 파일을 만들기만 하면 손쉽게 사용할 수 있다. (venv 라이브러리 이용) 터미널, 설치pip install Flask-SQLAlchemy app.py에 Flask와 Database를 연결하는 코드 입력from flask import Flaskimport osfrom flask_sqlalchemy import SQLAlchemybasedir = os.path.abspath(os.path.dirname(__file__))app = Flask(__name__)app.config['SQLALCHEMY_DATABASE_URI'] =\ 'sqlite:///' + os.path..