Python 108

[python]Squash the bugs

www.codewars.com/kata/56f173a35b91399a05000cb7/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 한 문장 안에서 가장 긴 단어의 길이를 구하는 문제입니다. 이 문제를 풀기 위해서는 다음과 같은 과정이 필요합니다. 1. 문장을 단어로 나누기 → split() 2. 단어의 길이 구하기 → len() 3. 가장 긴 길이 구하기 → max() def fin..

[python]Holiday VI - Shark Pontoon

www.codewars.com/kata/57e921d8b36340f1fd000059/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 바다에서 상어에게서 도망칠 수 있을지 없을지를 판단하는 것입니다. 도망칠 수 있으면 "Alive!"를 도망칠 수 없으면 "Shark Bait!"를 반환하면 됩니다. 이 문제에서는 다음의 5가지 변수가 주어집니다. 변수 설명 sharkDistance 상어와..

[python]Exclusive "or" (xor) Logical Operator

www.codewars.com/kata/56fa3c5ce4d45d2a52001b3c/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 입력받은 두 불리언을 xor 한 값을 반환하는 것입니다. xor이란 수리 논리학에서 주어진 2개의 명제 가운데 1개만 참일 경우를 말합니다. 벤 다이어 그램으로 보면 다음과 같습니다. 더 자세한 정보는 아래의 사이트에서 확인하시면 됩니다. ko.wikip..

[python]How good are you really?

www.codewars.com/kata/5601409514fc93442500010b/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 내 점수가 반 평균보다 높은지 낮은지 판별하는 문제입니다. 반 평균보다 높을 경우 True를 반환하고 낮을 경우 False를 반환하면 됩니다. 1. sum()과 len() 사용 sum() : 리스트 요소가 모두 숫자일 경우 리스트의 합을 구할 수 있습니다..

[python]Thinkful - Number Drills: Blue and red marbles

www.codewars.com/kata/5862f663b4e9d6f12b00003b/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 사실 영어 해석이 문제인 문제입니다.(뭔가... 말이 이상하네요.) 즉, 영어 해석을 잘한다면 풀이는 어렵지 않은 문제입니다. 가방 안에 파란 구슬과 빨간 구슬이 섞여 있을 때 파란색 구슬을 꺼낼 확률을 구하는 문제입니다. 입력 값은 (가방에 넣은 파란색..

[python]No zeros for heros

www.codewars.com/kata/570a6a46455d08ff8d001002/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 입력받은 수에서 숫자의 끝자리(1의 자리 수)가 0이 되지 않도록 만드는 것입니다. 만약 입력받는 수가 0일 경우는 0을 반환하면 됩니다. 이 문제는 % 연산자와 // 연산자를 이용하거나 rstrip()을 이용하면 쉽게 풀 수 있습니다. 1. % 연산자와..

[python]N-th Power

www.codewars.com/kata/57d814e4950d8489720008db/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 양의 정수만 있는 배열과 숫자 n을 입력으로 받습니다. 입력받은 배열에서 인덱스 n번째의 거듭제곱을 반환하는 문제입니다. 만약 배열 안에 인덱스 n이 존재하지 않을 경우 -1을 반환합니다. 거듭제곱의 ** 연산자를 사용하거나 pow(x, y)를 사용할 수..

[python]Grasshopper - Grade book

www.codewars.com/kata/55cbd4ba903825f7970000f5/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 입력받은 점수들의 평균에 따라서 학점을 다르게 출력하는 문제입니다. 우선적으로 이 문제를 풀려면 평균을 구해야 하며 이 평균을 if문을 사용하여 다른 결과 값을 나타내야 합니다. if문을 연습할 수 있는 초보자분들에게 좋은 문제입니다. :D def get..

numpy

0. numpy import numpy : python에서 Numpy를 사용하려면 먼저 import 시켜줘야 합니다. import numpy as np : numpy를 사용할 때 보편적으로 np라는 약자로 줄어서 사용을 많이 합니다. as 뒤에 원하는 것을 붙여도 좋지만 np로 붙여주는 것이 좋습니다. 1. array(리스트) : 리스트를 numpy를 사용할 수 있는 ndarray로 변환시켜줍니다. # array 사용법 import numpy as np array1 = np.array([[1], [2], [3]]) print(array1) 출력 결과 [[1] [2] [3]] 2. shape : ndarray의 모양을 (row, column) 형태로 알려줍니다. # shape 사용법 import numpy..

728x90