Question

In: Computer Science

write a python code to Determine the binary and decimal representations of the following hexadecimal numbers....

write a python code to Determine the binary and decimal representations of the following hexadecimal numbers. Store answers in the appropriate variables in the .py file.

(a) 0xfca1

(b) 0xc4d8

Solutions

Expert Solution

# Python code to convert
#Hexadecimal to decimal
#Hexadecimal to binary

  
# taking hexadecimal input from user
value = input("Please enter a string:\n")
  

# Code to convert hex to Decimal
n = int(value[2:], 16)

# Printing the Decimal Representation of Hexadecimal
print ("Decimal Representation of ",value," is ",str(n))


# Code to convert Decimal to binary
binaryString = " "
while n > 0:
binaryString = str(n % 2) + binaryString
n = n >> 1
result = binaryString
  
# Printing the Binary Representation of Hexadecimal
print ("Binary representation of ",value," is ",str(result))

Screenshot Code:

Output:


Related Solutions

Write a program in C++ that converts decimal numbers to binary, hexadecimal, and BCD. You are...
Write a program in C++ that converts decimal numbers to binary, hexadecimal, and BCD. You are not allowed to use library functions for conversion. The output should look exactly as follows: DECIMAL      BINARY                     HEXDECIMAL                      BCD 0                      0000 0000                   00                                            0000 0000 0000 1                      0000 0001                   01                                            0000 0000 0001 2                      0000 0010                   02                                            0000 0000 0010 .                       .                                   .                                               . .                       .                                   .                                               . 255                  1111 1111                   FF                                            0010 0101 0101
Convert the following binary values to hexadecimal and decimal (1 pt each) Write Hex Numbers as...
Convert the following binary values to hexadecimal and decimal (1 pt each) Write Hex Numbers as 0x##(ex 0x0A, 0xFF) Binary Hexadecimal Decimal 0001-1011 0x 0000-1000 0000-0100 0000-1001 0001-1111 1001-1001 0111-1010 1100-0010 1110-0101 1000-1010 0011-0100 0001-1001 0100-0011 1111-1111 1110-0111 0001-0010 0100-1000 0100-1110 1001-0001 0110-1100 Name: Convert the following hexadecimal values to binary and decimal Write binary numbers as 0000-0000 Hexadecimal Binary Decimal 0xf1 0xac 0x56 0x6c 0x32 0x30 0x05 0x28 0xf0 0x07 0x42 0xb9 0x6d 0x2f 0x71 0x0e 0x2d 0xfb 0xba...
Convert a list of decimal numbers into their binary and hexadecimal equivalents Add the elements of...
Convert a list of decimal numbers into their binary and hexadecimal equivalents Add the elements of each of these lists to generate a total sum Print the lists, and the total sum of each value C++ contains some built-in functions (such as itoa and std::hex) which make this assignment trivial. You may NOT use these in your programs. You code must perform the conversion through your own algorithm. The input values are: 5 9 24 2 39 83 60 8...
Develop a python program to convert two decimal numbers (A and B) to binary numbers. You...
Develop a python program to convert two decimal numbers (A and B) to binary numbers. You should generate B complement signal (flip all the bits of Input B,
Convert from hexadecimal to binary to decimal (PLEASE SHOW WORK) 1. B2 - binary: - decimal:...
Convert from hexadecimal to binary to decimal (PLEASE SHOW WORK) 1. B2 - binary: - decimal: 2. 37 - binary: - decimal: 3. 0A -binary: - decimal: 4. 11 - binary: - decimal:
Convert the following decimal numbers to 16-bit 2’s complement binary. Display your result in hexadecimal. a.3030...
Convert the following decimal numbers to 16-bit 2’s complement binary. Display your result in hexadecimal. a.3030 b.404 c.5050 d.-5050 e.-20000 Show work with steps
Program that does conversions (i.e. decimal to hexadecimal, binary to decimal) but needs to have a...
Program that does conversions (i.e. decimal to hexadecimal, binary to decimal) but needs to have a drop down menu to give you the option to choose with conversion you want to go from and convert into (JOptionPane). Cannot use the conversion tool that is built-in Java. Need to use equations or some sort. Please include comments on what is happening to understand.
Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal....
Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal. 1. Request input data type. 2. Request input data. 3. Request output data type. 4. Output the data. Use any algorithm
Convert from binary to decimal to hexadecimal (PLEASE SHOW ALL WORK) a. 1010 1011 - decimal:...
Convert from binary to decimal to hexadecimal (PLEASE SHOW ALL WORK) a. 1010 1011 - decimal: - hexadecimal b. 0011 0001 - decimal: - hexadecimal: c. 1110 0111 - decimal: - hexadecimal: d. 1111 1111 - decimal: - hexadecimal:
Write a method for binary tree in Python that can determine whether a binary tree is...
Write a method for binary tree in Python that can determine whether a binary tree is a binary search tree or not. The input should be a binary tree. The output should be true or false. True= binary tree meets the criteria to be a binary search tree. False= does not meet the criteria to be a binary search tree.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT