본문 바로가기
728x90
반응형

python399

[Python & Matplotlib] 아이리스(iris) 붓꽃 데이터셋을 활용하여 산점도 그래프 그리기 !! [Python & Matplotlib] 아이리스(iris) 붓꽃 데이터셋을 활용하여 산점도 그래프 그리기 !! Iris 데이터셋을 사용한 산점도 그래프 예시를 그려보았습니다.... Iris 데이터셋은 붓꽃(iris)의 세 종류(Setosa, Versicolour, Virginica)에 대한 150개의 샘플을 포함하며, 각 샘플은 꽃받침(sepal)과 꽃잎(petal)의 길이와 너비를 측정한 데이터입니다. 이 예시에서는 붓꽃 데이터셋의 꽃잎 길이와 너비를 사용하여 산점도 그래프를 그리고, 각 종류별로 점의 색을 다르게 하여 분류를 시각적으로 확인할 수 있습니다. import matplotlib.pyplot as plt import seaborn as sns from sklearn.datasets impor.. 2024. 2. 29.
[Python & Matplotlib] Matplotlib라이브러리를 활용한 산점도 그래프 그리기 !! [Python & Matplotlib] Matplotlib라이브러리를 활용한 산점도 그래프 그리기 !! 파이썬에서 matplotlib 라이브러리를 사용하여 산점도 그래프를 그리는 예시 입니다 ㅎ 예제코드 import matplotlib.pyplot as plt import numpy as np # 데이터 준비 x = np.random.rand(50) y = np.random.rand(50) colors = np.random.rand(50) sizes = 1000 * np.random.rand(50) # 산점도 그래프 그리기 plt.scatter(x, y, c=colors, s=sizes, alpha=0.5, cmap='viridis') # 컬러바 추가 plt.colorbar() # 제목 추가 plt.ti.. 2024. 2. 28.
[Python & Flask] 플라스크에서 static 폴더 경로 참조 하는 방법 !! [Python & Flask] 플라스크에서 static 폴더 경로 참조 하는 방법 !! Flask에서 HTML 파일과 CSS 파일을 연결하는 일반적인 방법은 Flask의 정적(static) 파일 제공 기능을 사용하는 것입니다. Flask는 정적 파일을 제공하기 위해 static 폴더를 사용하며, 이 폴더 내의 파일들은 URL을 통해 직접 접근할 수 있습니다. HTML 파일에서 CSS 파일을 참조할 때는 Flask의 url_for 함수를 사용하여 정적 파일 경로를 생성해야 합니다. 폴더 구조 예시 your_flask_app/ │ app.py └───templates/ │ └─your_template.html └───static/ └─css/ └─style.css CSS 파일 참조 방법 HTML 파일 내에서.. 2024. 2. 21.
[Python] 파이썬에서 영어가 아닌 단어 찾는 방법 !! [Python] 파이썬에서 영어가 아닌 단어 찾는 방법 !! 파이썬에서 리스트 안에 있는 단어가 영어인지 아닌지를 구분하기 위해, 주어진 단어가 영문 알파벳으로만 이루어져 있는지 확인하는 간단한 방법을 사용할 수 있습니다. str.isalpha()는 문자열이 알파벳으로만 구성되어 있는지를 확인하고, str.isascii()는 문자열이 ASCII 문자로만 구성되어 있는지를 확인합니다. ASCII 문자 집합에는 영문 알파벳이 포함되어 있으므로, 이 두 조건을 모두 만족하는 경우 해당 단어는 영어로 간주할 수 있습니다. 예제코드 def is_english_word(word): return word.isalpha() and word.isascii() words = ['apple', '사과', 'banana', .. 2024. 2. 14.
[Python & PyQt5] 파이큐티를 활용하여 타자게임 만드는 방법 !! #3 [Python & PyQt5] 파이큐티를 활용하여 타자게임 만드는 방법 !! #3 안녕하세요. pyqt5 라이브러리를 활용하여 간단한 타자게임을 만들기 시리즈 입니다. 추가 사항 - 점수 표시 - 시간바 표시 예제코드 import sys import random from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel, QLineEdit, QPushButton, QProgressBar from PyQt5.QtCore import QTimer, Qt from PyQt5.QtGui import QFont, QColor class TypingGame(QWidget): def __init__(self): super().__init__() se.. 2024. 2. 7.
[Python & PyQt5] 파이큐티를 활용하여 타자게임 만드는 방법 !! #2 [Python & PyQt5] 파이큐티를 활용하여 타자게임 만드는 방법 !! #2 안녕하세요. pyqt5 라이브러리를 활용하여 간단한 타자게임을 만들기 시리즈 입니다. 추가 사항 - 게임시작버튼 - 종료시간입력 기능 예제코드 import sys from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel, QLineEdit, QPushButton from PyQt5.QtCore import QTimer class TypingGame(QWidget): def __init__(self): super().__init__() self.initUI() self.words = ['apple', 'banana', 'cherry', 'date', 'el.. 2024. 2. 5.
[Python & PyQt5] 파이큐티를 활용하여 타자게임 만드는 방법 !! #1 [Python & PyQt5] 파이큐티를 활용하여 타자게임 만드는 방법 !! #1 안녕하세요. pyqt5 라이브러리를 활용하여 간단한 타자게임을 만들기 시리즈를 만들어 보려고 합니다 ! 게임은 5초마다 새로운 단어를 화면에 표시하고, 단어를 입력하면 단어를 새로운 단어로 교체 하는 로직입니다 ㅎ 예제코드 import sys from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel, QLineEdit from PyQt5.QtCore import QTimer, QTime class TypingGame(QWidget): def __init__(self): super().__init__() self.initUI() self.words = ['.. 2024. 1. 31.
[Python] 파이썬 리스트안에 있는 단어들 갯수(빈도수) 구하는 방법 !! (Counter 함수 사용) [Python] 파이썬 리스트안에 있는 단어들 갯수(빈도수) 구하는 방법 !! (Counter 함수 사용) Python에서 리스트에 있는 단어들의 빈도수를 계산하려면 collections 모듈의 Counter 클래스를 사용할 수 있습니다. Counter는 각 요소가 리스트에 나타나는 횟수를 세는 함수입니다. 다음은 이를 구현한 예제 코드입니다 예제코드 from collections import Counter # 단어들이 들어있는 리스트 words = ["apple", "banana", "apple", "orange", "banana", "apple"] # Counter를 사용하여 단어 빈도수 계산 word_counts = Counter(words) # 결과 출력 for word, count in word.. 2024. 1. 29.
[Python & PyQt5] 파이큐티를 활용하여 로또번호 추천해주는 프로그램 만드는 방법 !! [Python & PyQt5] 파이큐티를 활용하여 로또번호 추천해주는 프로그램 만드는 방법 !! 예제코드 import sys import random from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QLabel class LottoApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.setWindowTitle('Lotto Number Generator') self.setGeometry(300, 300, 300, 200) # 버튼 생성 self.btn = QPushButton('Generate Lotto Numb.. 2024. 1. 28.
728x90
반응형