• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Exercice BMC 4

a guest Jul 15th, 2014 187 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import os
2. binaire = str()
3. hexa=input("Saisissez le texte hexadecimal :")
4.
5. for lettre in hexa:
6.     if lettre == "0":
7.         binaire = binaire + str("0000")
8.     elif lettre == "1":
9.         binaire = binaire + str("0001")
10.     elif lettre == "2":
11.         binaire = binaire + str("0010")
12.     elif lettre == "3":
13.         binaire = binaire + str("0011")
14.     elif lettre == "4":
15.         binaire = binaire + str("0100")
16.     elif lettre == "5":
17.         binaire = binaire + str("0101")
18.     elif lettre == "6":
19.         binaire = binaire + str("0110")
20.     elif lettre == "7":
21.         binaire = binaire + str("0111")
22.     elif lettre == "8":
23.         binaire = binaire + str("1000")
24.     elif lettre == "9":
25.         binaire = binaire + str("1001")
26.     elif lettre == "A":
27.         binaire = binaire + str("1010")
28.     elif lettre == "B":
29.         binaire = binaire + str("1011")
30.     elif lettre == "C":
31.         binaire = binaire + str("1100")
32.     elif lettre == "D":
33.         binaire = binaire + str("1101")
34.     elif lettre == "E":
35.         binaire = binaire + str("1110")
36.     elif lettre == "F":
37.         binaire = binaire + str("1111")
38.     else:
39.         print("Saisie incorrecte")
40.
41. binaire = binaire.replace("0"," ")
42. binaire = binaire.replace("1","█")
43.
44. print(binaire[0:8])
45. print(binaire[8:16])
46. print(binaire[16:24])
47. print(binaire[24:32])
48. print(binaire[32:40])
49. print(binaire[40:48])
50. print(binaire[48:56])
51. print(binaire[56:64])
52.
53. os.system("pause")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top