본문 바로가기
반응형
별찍기(정사각형) star_string = " * " size = int(input("please input size")) for i in range(size): print(star_string *size) 2020. 2. 8.
숫자야구 게임 import random print("야구게임을 시작합니다 !!!\n--------------------------") i = random.randint(1,9) j = random.randint(1,9) k = random.randint(1,9) result = [str(i),str(j),str(k)] # 야구게임 정답 print('답: ',result) # 확인용 지울거얌 answer = [] strike_count = 0 ball_count = 0 try_count = 0 while(strike_count 2020. 2. 8.
로또 번호 생성기 import random lotto = [] game = int(input("lotto 게임 수를 입력하세요:")) print("===============================") for m in range(1,game+1): for a in range(1,8): i = random.randrange(1,46) lotto.append(i) lotto = list(set(lotto)) bonus = random.randint(1,46) lotto.sort() #리스트 정렬 for overlap in range(0,3): if (len(lotto) != 7): last = random.randint(1, 46) lotto.append(last) print(lotto,'+',lotto.pop()) l.. 2020. 2. 8.
구구단 게임 import random import time import numpy as np import sys def check(x): #정답 체크 global correct_count if(x == int(result)): print("정답!! :",str(result)) correct_count = correct_count + 1 elif( int(x) != int(result)): print("오답!! :",str(result)) # correct_count = correct_count - 1 else: print("뭐야??") def question(a): #문제 생성하기 global result b = random.randint(2, 4) numbers = [random.randint(2, 12) for .. 2020. 2. 8.
tensorflow 2.0 기초 분류 (가이드 기본 이미지 분류) # 파이썬 라이브러리 임포트 from __future__ import absolute_import, division, print_function, unicode_literals, unicode_literals import tensorflow as tf from tensorflow import keras import numpy as np import matplotlib.pyplot as plt # 패션 mnist 데이터 로드 fashion_mnist = keras.datasets.fashion_mnist (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data() # 이미지 출력시 필요한 변수 저장 class_nam.. 2020. 1. 17.
tensorflow 2.0 mnist간단 모델(가이드 - 초보용) # 텐서플로 라이브러리 임포트 from __future__ import absolute_import, division, print_function, unicode_literals !pip install -q tensorflow-gpu==2.0.0-rc1 import tensorflow as tf # MNIST 데이터셋 로드, 샘플 값을 정수 -> 부동소수 mnist = tf.keras.datasets.mnist #mnist 로드 (x_train, y_train), (x_test, y_test) = mnist.load_data() x_train, x_test = x_train / 255.0, x_test / 255.0 #계산의 편의를 위해 실수로 # layer를 쌓아 모델 구축. optimizer, los.. 2020. 1. 17.
tensorflow 2.0 기본 사칙연산 tensorflow 2.0 기본 문자열 출력 import tensorflow as tf a = tf.constant('hello world') a a.numpy() type(a) type(a.numpy()) constant를 사용한 사칙연산 A = tf.constant(2) B = tf.constatn(3) C = A + B C = tf.add(A,B) C C.numpy() D = 5 E = C * D E = tf.multiply(C,D) E E.numpy() 행렬곱 계산 Matrix_A = [[1,2],[3,4]] Matrix_B = [[3,4],[4,5]] Matrix_C = tf.matmul(Matrix_A, Matrix_B) Matrix_C 2020. 1. 11.
반응형