logo CodeStepByStep logo

print_binary

Language/Type: Python recursion

Write a recursive function named print_binary that accepts an integer and prints that number's representation in binary (base 2). For example, the call of print_binary(43) should pr101011 .

If the integer is negative, print the binary representation preceded by a minus sign. For example, the call of print_binary(-6) should pr-110 .

Function: Write a Python function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.