+ 2

What are some ways to write a function that converts int numbers to binary in python?

18th Jun 2020, 12:44 AM
Nathan Trapero
Nathan Trapero - avatar
2 ответов
+ 7
Nathan Trapero 1.using recursion: DecToBin(num): if num > 1: DecToBin(num // 2) print num % 2 2.using built in function: dec=89 print(bin(dec))
18th Jun 2020, 1:00 AM
Indira
Indira - avatar
+ 5
You can use bin () function
18th Jun 2020, 1:01 AM
Ayush Kumar
Ayush Kumar - avatar