K

@kimjuha19

1 부터 N까지의 합

Python
7 months ago
add = int(input()) for i in range(1, add): add += i print(add)

문자열 뒤집기

Python
7 months ago
word = input() reversed =word[::-1] print(reversed)

최대값 구하기

Python
7 months ago
n = int(input()) numbers = list(map(int, input().split())) print(max(numbers))

문자열에서 숫자의 합(isdigit)

Python
7 months ago
s = input() count = 0 for ch in s: if ch.isdigit(): count += int(ch) print(count)

문자열에서 숫자 개수 세기(isdigit)

Python
7 months ago
s = input() count = 0 for ch in s: if ch.isdigit(): count += 1 print(count)

문자열에서 숫자의 합

Python
7 months ago
s = input() total = 0 for ch in s: if '0' <= ch <= '9': total += int(ch) print(total)

문자열에서 숫자 개수 세기

Python
7 months ago
s = input() count = 0 for ch in s: if '0' <= ch <= '9': count += 1 print(count)

특정 문자 개수 세기

Python
7 months ago
text = input() ch = input() count = 0 for c in text: if c == ch: count += 1 print(count)

1~N까지의 합 중 소수 합만 출력

Python
7 months ago
N = int(input("")) total = 0 for i in range(1, N + 1, 2): total += i print(total)

1~N까지의 합 중 짝수 합만 출력

Python
7 months ago
N = int(input("")) total = 0 for i in range(2, N + 1, 2): total += i print(total)

소수 판별

Python
7 months ago
num = int(input()) if num < 2: print("NO") else: for i in range(2, int(num ** 0.5) + 1): if num % i == 0: print("NO") break else:

1 부터 N까지 합이 100 이상이 되는 시점 찾기

Python
7 months ago
n = 1 t = 0 while t < 100: t += n n += 1 print(n - 1)

가장 작은 수 구하기

Python
7 months ago
n = int(input()) numbers = list(map(int, input().split())) print(min(numbers))

양수 음수 0 개수 세기

Python
7 months ago
numbers = list(map(int, input().split())) pos = 0 neg = 0 zero = 0 for n in numbers: if n > 0: pos += 1 elif n < 0:

구구단 출력

Python
7 months ago
num = int(input()) for i in range(1,10): print(num * i)

3의 배수 갯수 세기

Python
7 months ago
n = int(input()) print(n // 3)

파이썬 알고리즘(피보나치)

Python
8 months ago
n = int(input()) a,b = 0, 1 for i in range(n-1): a,b = b, a + b print(b)

파이썬 알고리즘(문자열 압축)

Python
8 months ago
a = input() result = "" count = 1 for i in range(len(a)- 1): if a[i] == a[i+1]: count += 1 else: result += a[i] + str(count) count = 1

파이썬 알고리즘(숫자 삼각형)

Python
8 months ago
a = int(input()) num = 1 for i in range(1,a + 1): for j in range(i): print(num,end = ' ') num += 1 print()

파이썬 알고리즘(회문 개수 세기)

Python
8 months ago
num = list(map(int ,input().split())) count = 0 for n in num: s = str(n) if s == s[::-1]: count += 1 print(count)