help me explain this python code step boy step choice = True while choice==True: n = int(input(" 1. Binary To decimal\n\ 2. Decimal to Hexadecimal\n\ 3. Binary to Hexadecimal\n\ 4. Decimal to...


help me explain this python code step boy step





choice = True

while choice==True:
        n = int(input("

1. Binary To decimal\n\

2. Decimal to Hexadecimal\n\

3. Binary to Hexadecimal\n\

4. Decimal to Binary\n\

5. Hexadecimal to Decimal\n\

6. Hexadecimal to Binary\n\

7. Addition of Binary numbers\n\

8. Subtraction of Binary numbers\n\

9. Multiplication of Binary numbers\n\

10. Division of Binary numbers\n\

11. exit program\n\

Enter your choice: ")
the rest is on the images











15<br>if n==1:<br>54<br>if b >= 32768:<br>55<br>b = b - 65536<br># Code to convert binary to decimal<br>s = input(= 32768: # Code to convert binary to hexadecimal s = input("\nEnter Binary value: ") print("Hexadecimal value is: ", hex(int(int(s,2)))[2:].u 26 65 27 66 a = a - 65536 28 67 if b >= 32768: 29 68 b = b - 65536 30 elif n==4: 69 diff = a - b 70 print ("Decimal value of difference: ", diff) # Code to convert decimal to binary s = int(input("\nEnter Decimal value: ")) print("Binary value is: ", bin(s).replace ("Ob", "")) 31 32 71 33 72 elif n==9: # Code to Multiplication two binary numbers s = input("\nEnter first Binary value in 2's complement: a = int(s,2) s = input("\nEnter second Binary value in 2's complement b = int(s,2) 34 73 35 74 36 elif n==5: 75 37 # Code to convert hex to decimal 76 S = input("\nEnter Hexadecimal value: ") print("Decimal value is: ", int(s, 16)) 38 77 39 78 if a >= 32768: 40 79 a = a - 65536 41 elif n==6: 80 if b >= 32768: 81 b = b - 65536 # Code to convert hex to binary s = input("\nEnter Hexadecimal value: ") print("Binary value is: ", bin(int(s, 16))[2:].upper()) 42 43 82 mul = a * b 44 83 print ("Decimal value of product: ". mul) 45 84 46 elif n==7: 85 86 elif n==10: # Code to add two binary numbers s = input("\nEnter first Binary value in 2's complement: a = int(s,2) s = input("\nEnter second Binary value in 2's complement b = int(s,2) if a >= 32768: 47 # Code to Division two binary numbers s = input("\nEnter first Binary value in 2's complement: a = int(s,2) s = input("\nEnter second Binary value in 2's complement b = int(s,2) 48 87 49 88 50 89 51 90 52 91 53 a = a - 65536 92 if a >= 32768: "/>
Extracted text: 15 if n==1: 54 if b >= 32768: 55 b = b - 65536 # Code to convert binary to decimal s = input("\nEnter Binary value: ") print("Decimal value is: ",int(s,2)) 16 sum = a + b print("Decimal value of sum: 17 araa. 56 18 57 sum) 19 58 20 elif n==2: 59 elif n==8: # Code to subtract two binary numbers s = input("\nEnter first Binary value in 2's complement: 21 # Code to convert decimal to hexadecimal 60 S = input("\nEnter Decimal value: ") print ("Hexadecimal value is: ", hex(int(s))[2:].upper()) 22 61 a = int(s,2) s = input("\nEnter second Binary value in 2's complement b = int(s,2) 23 62 24 63 25 elif n==3: 64 if a >= 32768: # Code to convert binary to hexadecimal s = input("\nEnter Binary value: ") print("Hexadecimal value is: ", hex(int(int(s,2)))[2:].u 26 65 27 66 a = a - 65536 28 67 if b >= 32768: 29 68 b = b - 65536 30 elif n==4: 69 diff = a - b 70 print ("Decimal value of difference: ", diff) # Code to convert decimal to binary s = int(input("\nEnter Decimal value: ")) print("Binary value is: ", bin(s).replace ("Ob", "")) 31 32 71 33 72 elif n==9: # Code to Multiplication two binary numbers s = input("\nEnter first Binary value in 2's complement: a = int(s,2) s = input("\nEnter second Binary value in 2's complement b = int(s,2) 34 73 35 74 36 elif n==5: 75 37 # Code to convert hex to decimal 76 S = input("\nEnter Hexadecimal value: ") print("Decimal value is: ", int(s, 16)) 38 77 39 78 if a >= 32768: 40 79 a = a - 65536 41 elif n==6: 80 if b >= 32768: 81 b = b - 65536 # Code to convert hex to binary s = input("\nEnter Hexadecimal value: ") print("Binary value is: ", bin(int(s, 16))[2:].upper()) 42 43 82 mul = a * b 44 83 print ("Decimal value of product: ". mul) 45 84 46 elif n==7: 85 86 elif n==10: # Code to add two binary numbers s = input("\nEnter first Binary value in 2's complement: a = int(s,2) s = input("\nEnter second Binary value in 2's complement b = int(s,2) if a >= 32768: 47 # Code to Division two binary numbers s = input("\nEnter first Binary value in 2's complement: a = int(s,2) s = input("\nEnter second Binary value in 2's complement b = int(s,2) 48 87 49 88 50 89 51 90 52 91 53 a = a - 65536 92 if a >= 32768:
84<br>85<br>elif n==10:<br># Code to Division two binary numbers<br>s = input(= 32768: 86 87 88 89 a %3D 90 %3D 91 92 93 a - 65536 a %3D 94 if b >= 32768: 95 b = b - 65536 a//b onb print("Decimal value of quotient: ", quo) 96 97 98 99 100 elif n==11: 101 break 102 103 else: 104 print("\nInvalid input") 105 106 "/>
Extracted text: 84 85 elif n==10: # Code to Division two binary numbers s = input("\nEnter first Binary value in 2's complement: int(s,2) s = input("\nEnter second Binary value in 2's complement b = int(s,2) if a >= 32768: 86 87 88 89 a %3D 90 %3D 91 92 93 a - 65536 a %3D 94 if b >= 32768: 95 b = b - 65536 a//b onb print("Decimal value of quotient: ", quo) 96 97 98 99 100 elif n==11: 101 break 102 103 else: 104 print("\nInvalid input") 105 106
Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here