[파이썬] 문제 : 학생들의 점수에 따른 등급 함수
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.
알고리즘 시간복잡도 그래프 및 빠른 순서
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.
[파이썬] 터틀(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.
[파이썬] 임의의 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.