본문 바로가기

Study(매일매일한걸음씩)/Python15

[Study] Python, eval,lamda,map 공부하다가 몰라서 정리 1. eval(쉽게 이야기 하면 문자나 숫자로 구성된 문자를 파이션 표현식으로 바꾼다(산술식) 하지만 사용하기 매우 조심해야 한다. eval is a built-in function in Python that evaluates a string as a Python expression. The expression can be a simple value, such as a string or a number, or a more complex expression, such as an arithmetic expression. For example, the following code will evaluate the string "2 + 3" as a Python expression and p.. 2023. 2. 1.
Mini -Project #1-1 3자리 숫자 야구 게임 with openai(좌절) chatgpt있어서 한번 해봤는데 좌절 초보인 나하고 비교가 안됨 https://chat.openai.com/chat import random def baseball_game(): target = random.sample(range(0, 10), 3) tries = 0 while True: tries += 1 guess = list(map(int, input("Enter your guess (3 digits): ").strip())) if len(guess) != 3: print("Invalid input. Try again.") continue strikes = 0 balls = 0 for i in range(3): if guess[i] == target[i]: strikes += 1 elif gues.. 2023. 1. 31.
#1 아무것도 모른 상태에서 처음 하는 Python GUI(PySide6) - 버튼 만들기 버튼 만들기 from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton import sys app = QApplication(sys.argv) window = QMainWindow() window.setWindowTitle("push button box") button = QPushButton() button.setText("Press me") window.setCentralWidget(button) window.show() app.exec() 결과 The QApplication class manages the GUI application’s control flow and main settings. The QMainWindow class p.. 2023. 1. 11.
#1 python pyside6 qt로 해보기(pyside6-uic.exe 없어서 고생함) pyside6-uic 찾아도 없어서 찾다가 고생고생 하다가 다른 사람도 고생하는 거 방지 하기위해 작성함 두가지 방법 있음 ui(qt designer 파일)을 이용하는 방법 나머지하나는 ui파일을 py로 변환해서 이용하는 방법이 있다. 순서(기본) python 설치(홈페이지) https://www.python.org/ vsc(visual studio code) 설치(홈페이지) https://code.visualstudio.com/ qt for python 설치(비주얼 스튜디오 코드 안에서) pyside6 설치 pip install PySide6 프로젝트 만들기 coding https://doc.qt.io/qtforpython/tutorials/basictutorial/widgets.html 참조 impo.. 2023. 1. 10.