Question: I haven't leant about the while or for in python, how can I do this? 3.2 Decimal-to-Byte Calculator In [67]: > # decimal-to-byte calculators executed

 I haven't leant about the while or for in python, how

I haven't leant about the while or for in python, how can I do this?

3.2 Decimal-to-Byte Calculator In [67]: > # decimal-to-byte calculators executed in 33ms, finished 00:21:26 2020-09-06 decimal 40 byte: 00100100 Exercise Assign to byte a string of 8 bits that represents the value of decimal , a non-negative decimal integer from 0 to 28 1 = 255. Hint: Use // and %. In [ ]: def decimal_to_byte(decimal): # YOUR CODE HERE byte = a + b + C + d + e + f a = 1 g+h return byte executed in 8ms, finished 10:44:54 2020-09-09 In [ ]: == 8 # tests def test_decimal_to_byte(byte, decimal): byte_ = decimal_to_byte(decimal) correct = byte == byte_ and isinstance (byte, str) and len(byte) if not correct: print fi{decimal} should be represented as the byte {byte), not {byte_}. ) assert correct test_decimal_to_byte('01100111', 103) test_decimal_to_byte('00000011', 3) test_decimal_to_byte('00011100', 28) executed in 7ms, finished 10:44:54 2020-09-09 In [ ]: # decimal-to-byte calculator executed in 33ms, finished 10:44:55 2020-09-09

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!