본문 바로가기

전체 글1007

[파이썬] 문제 : 학생들의 점수에 따른 등급 함수 grades = (["A+",[100, 95]], ["A",[94,90]] , ["B+",[89,85]], ["B",[84,80]] , ["C+",[79,75]], ["C",[74,70]] , ["D+",[69,65]], ["C",[64,60]] , ["F",[59,0]]) members = (('choi',93), ('han',50), ('jung',92), ('kang',68), ('kim',80) , ('lee',90), ('moon',65), ('na',100), ('park',75), ('song',75)) def find_grade(inscore): outgrade = '' for g in grades: # ["A+",[100, 95]] 하나씩 꺼냄 # print(inscore, g, g[0].. 2023. 5. 15.
[파이썬] 문제 : (sklearn)Wine 데이터 분류 (DecisionTree / SVC / GaussianNB) from sklearn.datasets import load_wine from sklearn.tree import DecisionTreeClassifier from sklearn.naive_bayes import GaussianNB from sklearn.svm import SVC from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score import pandas as pd import numpy as np from sklearn import metrics data = load_wine() wine_data = data.data # feature 데이터 wine_target = data.tar.. 2023. 5. 13.
알고리즘 시간복잡도 그래프 및 빠른 순서 import matplotlib.pyplot as plt import numpy as np x = np.arange(1, 100) fig, axs = plt.subplots(2, 3) plt.rcParams['font.family'] = 'NanumGothic' # 한글 가능하도록 폰트 설정 fig.suptitle("시간 복잡도에서 빠른 순서:O(1) < O(log n) < O(n) < O(n log n) < O(n^2) < O(n^3) < O(2^n) < O(n!)") axs[0, 0].plot(x, np.ones(99)) axs[0, 0].set_title('O(1)') axs[0, 1].plot(x, np.log2(x)) axs[0, 1].set_title('O(log n)') axs[0, 2].p.. 2023. 5. 12.
[파이썬] 문제 : tkinter 숫자 맞추기 게임 from tkinter import * import random window = Tk() window.geometry("360x200") # 창 크기설정 window.title("할 일") # 창 제목설정 window.option_add("*Font","맑은고딕 12") # 폰트설정 # window.resizable(False, False) # x, y 창 크기 변경 불가 no = random.randint(1, 50) def btnGuess(): # 함수 정의 global no guess = int(entry.get()) if guess == no: hint['text'] = "Correct" elif guess > no: hint['text'] = "High" elif guess < no: hint[.. 2023. 5. 12.
[파이썬] 문제 : tkinter canvas에 사각형 그리고, 상하좌우 이동 from tkinter import * # tkinter 라이브러리에 모든 함수를 사용하겠다. root = Tk() # root라는 창을 생성 root.geometry("600x400") # 창 크기설정 root.title("yeachan_yeachan") # 창 제목설정 # root.option_add("*Font","맑은고딕 25") # 폰트설정 # root.resizable(False, False) # x, y 창 크기 변경 불가 rec_length = 100 # 사각형 한 변의 길이 win_w = 600 # 윈도우 크기 win_h = 400 x1 = win_w//2 - (rec_length//2) # 초기 사각형의 x1 좌표 y1 = win_h//2 - (rec_length//2) # 초기 사각형.. 2023. 5. 12.
[파이썬] tkinter 할 일 리스트(Text) 만들기 from tkinter import * window = Tk() window.geometry("360x200") # 창 크기설정 window.title("할 일") # 창 제목설정 # window.option_add("*Font","맑은고딕 12") # 폰트설정 window.resizable(False, False) # x, y 창 크기 변경 불가 def btnAdd(): # 함수 정의 text.insert(END, ent.get()+"\n") # 입력창의 내용을 리스트 박스 마지막에 추가 ent = Entry(window) # root라는 창에 입력창 생성 ent.config(width=25) # 버튼 크기 ent.config(font=("Arial",15)) ent.pack() # 입력창 배치 btn.. 2023. 5. 10.
[파이썬] 터틀(turtle) 임의의 다각형,색,좌표로 그리기 import turtle import random turtle.setup(600, 600) colors = ['red','yellow','blue','green','skyblue','white','orange'] def draw_shape(t, c, length, sides, x, y): turtle.speed(t) # 속도 turtle.penup() # 그리지 않으면서 좌표 이동하기 위해 펜을 듬 turtle.goto(x, y) # 좌표로 이동 turtle.pendown() # 이제부터 그리기 위해 펜을 내임 turtle.pencolor('black') # 펜색 지정 turtle.fillcolor(c) # 채우기 색 지정 turtle.begin_fill() # 채우기 시작 for i in range(s.. 2023. 5. 10.
[파이썬] 클래스의 스페셜메소드(__call__) class Student(): def __call__(self, name, *args): return sum(args) / len(args) student = Student() test = student("A", 90,90,90,90) print(test == 90) print(test != 90) print(test > 90) print(test >= 90) print(test < 90) print(test 2023. 5. 10.
[파이썬] 임의의 5개의 정수와 이 정수들의 합들로 이루어진 x데이터로 학습해서 임의의 5개 정수 예측하기 A,B,C,D,E 5개의 정수가 있을때, A + B, A + C, A + D, A + E, B + C, B + D, B + E, C + D, C + E, D + E 인 데이터를 가지고 A~E 정수를 찾는 딥러닝 코드. import numpy as np from tensorflow.keras.layers import Dense, Input from tensorflow.keras.models import Model from tensorflow.keras.optimizers import Adam import tensorflow as tf gpus = tf.config.experimental.list_physical_devices('GPU') if gpus: # 텐서플로가 첫 번째 GPU만 사용하도록 제한 tr.. 2023. 5. 10.
[C언어] 문제 : 컴퓨터와 사람이 1~5 사이의 수를 입력해 합이 31에 먼저 되는 쪽이 이기는 게임 컴퓨터와 숫자 31을 먼저 말하면 지는 게임을 하는 프로그램을 작성하시오. 컴퓨터는 1 ~ 5개의 숫자를 랜덤으로 생성 cnum = rand() % 5 + 1 ; => 1 ~ 5의 숫자 사람도 1 ~ 5 개이 숫자를 말하는 프로그램 먼저 31에 도달하면 종료 반복문과 조건으로 수행하는 프로그램을 C언어 코드 #include #include #include int main(void) { int cnum, p, c_sum, p_sum; srand((unsigned int)time(NULL)); c_sum = 0; p_sum = 0; while(c_sum < 31 && p_sum < 31){ cnum = rand()%5+1; printf("num : "); scanf("%d", &p); c_sum = c_su.. 2023. 5. 10.
728x90
반응형