MapleStory Finger Point

πŸ’Ž Python/Python_Code

μ§„μˆ˜ λ³€ν™˜ ν”„λ‘œκ·Έλž¨ - 파이썬 for Beginner (2판)

HYEJU01 2024. 3. 18. 20:53

 

βœ…μ§„μˆ˜ λ³€ν™˜ ν”„λ‘œκ·Έλž¨

sel = int(input("μž…λ ₯ μ§„μˆ˜ κ²°μ • (16,10,8,2) :"))
num = input("κ°’ μž…λ ₯: ")

if sel == 16 :
    num10 = int(num,16)


if sel == 10 :
    num10 = int(num,10)


if sel == 8 :
    num10 = int(num,8)


if sel == 2 :
    num10 = int(num,2)


print("16μ§„μˆ˜ ==> ", hex(num10))
print("8μ§„μˆ˜ ==> ", oct(num10))
print("2μ§„μˆ˜ ==> ", bin(num10))
print("10μ§„μˆ˜ ==> ", num10)

 

 

 

 

βœ… μ§„μˆ˜ λ³€ν™˜ ν”„λ‘œκ·Έλž¨ (μ‘μš©) 

: 같지 μ•Šλ‹€λŠ” !=  μ‚¬μš©

: κ΄€κ³„μ—°μ‚°μž and μ‚¬μš©

sel = int(input("μž…λ ₯ μ§„μˆ˜ κ²°μ • (16,10,8,2) :"))\

if sel != 16 and 10 and 8 and 2 :
    print("16,10,8,2 쀑에 ν•˜λ‚˜λ§Œ μž…λ ₯ν•˜μ„Έμš”")
    exit()
    
num = input("κ°’ μž…λ ₯: ")



if sel == 16 :
    num10 = int(num,16)


if sel == 10 :
    num10 = int(num,10)


if sel == 8 :
    num10 = int(num,8)


if sel == 2 :
    num10 = int(num,2)




print("16μ§„μˆ˜ ==> ", hex(num10))
print("8μ§„μˆ˜ ==> ", oct(num10))
print("2μ§„μˆ˜ ==> ", bin(num10))
print("10μ§„μˆ˜ ==> ", num10)