Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program a function binary_add(a, b) that computes the sum of the binary numbers a = (9-1,4-2,...,40)2 and b = (b- bj-2... bu)2 using the

 

Program a function binary_add(a, b) that computes the sum of the binary numbers a = (9-1,4-2,...,40)2 and b = (b- bj-2... bu)2 using the algorithm discussed in lecture. No credit will be given to functions that employ any other implementation. The function can not use built-in functions that already perform some kind of binary representation or addition of binary numbers. For example, the function implementation can not use the functions bin() or int(a, base=2). The function should satisfy the following: 1. INPUT: . a - a string of the O's and 1's that make up the first binary number. The string may contain spaces. b - a string of the O's and 1's that make up the first binary number. The string may contain spaces. 2. OUTPUT: the string of O's and 1's that is the result of computing a + b. The string must be separated by spaces into blocks of 4 characters or less, beginning at the end of the string. EXAMPLE: >> binary_add( '10 1011', '11011') 100 0110 In [ ]: def binary_add(a, b): #FIXME: Implement this method pass

Step by Step Solution

3.52 Rating (152 Votes )

There are 3 Steps involved in it

Step: 1

Every concept has been explained by adding comments to it Python Code Explained with comments This i... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming Logic & Design Comprehensive

Authors: Joyce Farrell

9th edition

978-1337102070

More Books

Students also viewed these Accounting questions