Algorithm/CodeUp
[CodeUp 기초 100제]1033 : [기초-출력변환] 10진 정수 입력받아 16진수로 출력하기2(풀이 성공)
전봇대파괴자
2020. 11. 26. 16:57
입력:
10진수 1개가 입력된다.
출력:
16진수(대문자)로 출력한다.
내 코드:
x = int(input())
print(hex(x)[2:].upper())
또 다른 풀이:
x=int(input())
print('%X' % x)
# 또 다른 풀이
x = int(input())
print(format(x, 'x').upper())
Comment: 앞의 문제들과 같은 방식으로 풀면 된다. 대문자로 출력 시 코드에서처럼 upper() 함수를 덧붙이거나 '%x' 대신 '%X'를 사용할 수 있다.