| Conditions | 1 |
| Total Lines | 15 |
| Code Lines | 3 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | def to_binary(int_digit, length=4): |
||
| 2 | """Convert a digit into binary string. |
||
| 3 | |||
| 4 | Arguments: |
||
| 5 | int_digit {str} -- the digit needed to be convert |
||
| 6 | |||
| 7 | Keyword Arguments: |
||
| 8 | length {int} -- length of converted string (default: {4}) |
||
| 9 | |||
| 10 | Returns: |
||
| 11 | str -- a string with specific length converted from int |
||
| 12 | |||
| 13 | """ |
||
| 14 | format_str = '{:0>%ds}' % length |
||
| 15 | return format_str.format(bin(int(int_digit))[2:]) |
||
| 16 | |||
| 33 |