문자열 다루기
문자열을 대문자로 바꾸기 string.upper()
myString = 'hello world'
print(myString.upper())
# HELLO WORLD
문자열을 소문자로 바꾸기 string.lower()
myString = 'HELLO WORLD'
print(myString.lower())
# hello world
모든 문자열이 대문자인지 확인 string.isupper()
하나라도 소문자가 포함되면 False
upperString = 'HELLO WORLD'
print(upperString.isupper())
# True
lowerString = 'hello world'
print(lowerString.isupper())
# False
모든 문자열이 소문자인지 확인 string.islower()
하나라도 대문자가 포함되면 False
lowerString = 'hello world'
print(lowerString.islower())
# True
upperString = 'HELLO WORLD'
print(upperString.islower())
# False
문자열의 대소문자 변환 string.swapcae()
대문자 -> 소문자
소문자 -> 대문자
mixedString = 'hello WORLD'
print(mixedString.swapcase())
# HELLO world
두 수의 최대공약수 math.gcd(a,b)
import math
a = 10
b = 15
gcd = math.gcd(a, b)
print(gcd)
# 5
두 수의 최소공배수 a * b / math.gcd(a, b)
import math
a = 10
b = 15
lcm = a * b / math.gcd(a, b)
print(lcm)
# 30
'프로그래밍 > 코딩 테스트' 카테고리의 다른 글
[코테] 그림 (실버1, 43%) (0) | 2025.01.28 |
---|---|
[코테] 신고 결과 받기 ( Lv.1 (39%)) (0) | 2024.10.05 |
[코테] 순위 Lv.3 (40%) (0) | 2024.02.19 |
n진법으로 변환하는 함수 (1) | 2023.10.01 |
[코테] 콜라 문제 Lv. 1 (67%) (0) | 2023.08.31 |
댓글