One more question to get some help as my professor is not responding to emails and this class is 100% online.
Here is the information and what I have created. Let me know!
GUIDELINES:
-Develop an algorithm to convert from binary to decimal using a power of base.
-Define a function named repToDecimal that expects two arguments (second should
be a base), a string, and an integer.
-Function should use a lookup table to find the value of any digit and is
initialized before the function is defined.
-Value stored with each key should be the integer that the digit represents.
-Main loops of the function should convert each digit to uppercase,
look up its value in the table, and use this value in the computation.
-MAIN function included to test the conversion function with numbers in several
binToDecimalTable= {'0':'0', '1':'1', '2':'2','3':'3', '4':'4',
'5':'5', '6':'6', '7':'7', '8':'8', '9':'9', '10':'A',
'11':'B', '12':'C', '13':'D', '14':'E', '15':'F'}
def repToDecimal(number, table):
binary = ''
for digit in number:
binary = binary + table[digit]
return binary
repToDecimal ("29D",binToDecimalTable)

New Topic/Question
Reply



MultiQuote




|