Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 41c337f

Browse files
Merge pull request #244 from CuiXiaoDao/update_2
Update 2
2 parents f427590 + 127bf6b commit 41c337f

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

dec_to_hex.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
mydict={
2-
'0':'0','1':'1','2':'2','3':'3','4':'4','5':'5','6':'6','7':'7','8':'8','9':'9','10':'A','11':'B',
3-
'12':'C','13':'D','14':'E','15':'F'
4-
}
5-
dec_num=input('Enter the decimal number\n');
6-
dec_num=int(dec_num)
7-
value=""
8-
while dec_num>0:
9-
value+=mydict[str(dec_num%16)]
10-
dec_num=dec_num//16
11-
hex_value=value[::-1]
12-
print(hex_value)
1+
dec_num=input('Enter the decimal number\n')
2+
print(hex(int(dec_num)))

0 commit comments

Comments
 (0)