subject

Python

programming exercise 5.5

in convert. py, define a function named reptodecimal that expects two arguments, a string, and an integer. the second argument should be the base. for example, reptodecimal("10", 8) returns 8, whereas reptodecimal("10", 16) returns 16.

the function should use a lookup table to find the value of any digit. make sure that this table (it is actually a dictionary) is initialized before the function is defined.

for its keys, use the 10 decimal digits (all strings) and the letters a . . f (all uppercase). the value stored with each key should be the integer that the digit represents. (the letter a associates with the integer value 10, and so on.)

the main loop of the function should convert each digit to uppercase, look up its value in the table, and use this value in the computation.

include a main function that tests the conversion function with numbers in several bases.

an example of main and correct output is shown below:

def main():
print(reptodecimal('10', 10))
print(reptodecimal('10', 8))
print(reptodecimal('10', 2))
print(reptodecimal('10', 16))
10
8
2
16

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 03:50
You are working as a security analyst in a company xyz that owns the whole subnet range of 23.0.0.0/8 and 192.168.0.0/8. while monitoring the data, you find a high number of outbound connections. you see that ip's owned by xyz (internal) and private ip's are communicating to a single public ip. therefore, the internal ip's are sending data to the public ip. after further analysis, you find out that this public ip is a blacklisted ip, and the internal communicating devices are compromised. what kind of attack does the above scenario depict?
Answers: 3
question
Computers and Technology, 23.06.2019 00:10
My has been slow anyone else’s ?
Answers: 1
question
Computers and Technology, 23.06.2019 01:30
Negative methods of behavior correction include all but this: sarcasm verbal abuse setting an example for proper behavior humiliation
Answers: 1
question
Computers and Technology, 23.06.2019 17:10
Ac++an of of pi. in , pi is by : pi = 4 – 4/3 + 4/5 – 4/7 + 4/9 - 4/11 + 4/13 - 4/15 + 4/17 . ., to pi (9 ). , if 5 to pi,be as : pi = 4 - 4/3 + 4/5 - 4/7 + 4/9 = 4 – 1. + 0.8 - 0. + 0. = 3.. atoofbe to pi?
Answers: 2
You know the right answer?
Python

programming exercise 5.5

in convert. py, define a function named re...
Questions
Questions on the website: 13722361