Function Definition Include Docstring Describes Function Arguments Returned Value 5 Define Q43896599

Each function definition should include a docstring thatdescribes what the function does, its arguments, and its returnedvalue.
5. Define a Python function unsignedDecimalToBinary that expectsan unsigned decimal integer as an argument and returns thecorresponding string of binary digits. You should assume that thecaller provides a correctly formed integer, so no error handling isnecessary.
9. Using the functions you already have defined, define afunction decimalToTwosComp that expects a signed decimal integer asan argument and returns the corresponding twos-complement string ofbinary digits.
10. Define a function signExtend that expects a twos complementstring of binary digits and the total number of bits as argumentsand returns the corresponding twos complement string of binarydigits, sign-extended to that number of bits.
def invert(bitString): III Returns the bit string with the bits inverted.” invertedString = ” for bit in bitString: if bit == ‘1’: invertedString += ‘O. else: invertedString += ‘1’ return invertedString def main(): “Test bed for decimal/binary conversion functions.” print (“11001 ->”, invert(“00110”)) print (“O ->”, unsignedBinaryToDecimal(“”)). print (“6 ->”, unsignedBinaryToDecimal(“110”)) print (“O ->”, unsignedDecimalToBinary(0)) print (“110 ->”, unsignedDecimalToBinary (6)) print (“110 ->”, addone(“101”)) print (“5 ->”, twosCompToDecimal(“0101”)) print (“-5 ->”, twos CompToDecimal(“1011”)) print (“0101 ->”, decimalToTwosComp (5)) print (“1011 ->”, decimalToTwosComp(-5)). print (“00000101 ->”, signExtend(decimalToTwosComp(5), 8)) print (“11111011 ->”, signExtend(decimalToTwosComp(-5), 8)). if -_name__ == “__main__”: main() Show transcribed image text def invert(bitString): III Returns the bit string with the bits inverted.” invertedString = ” for bit in bitString: if bit == ‘1’: invertedString += ‘O. else: invertedString += ‘1’ return invertedString def main(): “Test bed for decimal/binary conversion functions.” print (“11001 ->”, invert(“00110”)) print (“O ->”, unsignedBinaryToDecimal(“”)). print (“6 ->”, unsignedBinaryToDecimal(“110”)) print (“O ->”, unsignedDecimalToBinary(0)) print (“110 ->”, unsignedDecimalToBinary (6)) print (“110 ->”, addone(“101”)) print (“5 ->”, twosCompToDecimal(“0101”)) print (“-5 ->”, twos CompToDecimal(“1011”)) print (“0101 ->”, decimalToTwosComp (5)) print (“1011 ->”, decimalToTwosComp(-5)). print (“00000101 ->”, signExtend(decimalToTwosComp(5), 8)) print (“11111011 ->”, signExtend(decimalToTwosComp(-5), 8)). if -_name__ == “__main__”: main()
Expert Answer
Answer to Each function definition should include a docstring that describes what the function does, its arguments, and its return…
OR