Python - 문제 미리보기

문제 1873

easy
문자열을 대문자로 변환하는 메서드는?
text = "hello world"
result = text.______()
print(result)  # "HELLO WORLD"
A. `uppercase`
B. `upper`
C. `toUpper`
D. `capitalize`

정답: B



⦁ Python 문자열 대소문자 변환 메서드:

upper() - 모든 문자를 대문자로:
text = "hello world"
print(text.upper())    # "HELLO WORLD"

mixed = "Hello World!"
print(mixed.upper())   # "HELLO WORLD!"

다른 대소문자 관련 메서드들:
text = "hello world"

print(text.lower())      # "hello world" (소문자)
print(text.capitalize()) # "Hello world" (첫 글자만 대문자)
print(text.title())      # "Hello World" (각 단어 첫 글자 대문자)

upper() 메서드의 특징:
⦁ 불변성: 원본 문자열은 변경되지 않음
⦁ 새 객체 반환: 새로운 문자열 객체 생성
⦁ 모든 문자: 알파벳 문자만 변환, 숫자/기호는 그대로

💡 학습 팁

이 문제를 포함한 Python 과목의 모든 문제를 순차적으로 풀어보세요. 진행상황이 자동으로 저장되어 언제든지 이어서 학습할 수 있습니다.