{"id":8083,"date":"2021-06-07T19:14:40","date_gmt":"2021-06-07T13:44:40","guid":{"rendered":"https:\/\/python-programs.com\/?p=8083"},"modified":"2021-11-22T18:38:37","modified_gmt":"2021-11-22T13:08:37","slug":"python-program-to-print-binary-representation-of-a-number","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-print-binary-representation-of-a-number\/","title":{"rendered":"Python Program to Print Binary Representation of a Number"},"content":{"rendered":"

Binary Representation:<\/strong><\/p>\n

Binary (or base-2) is a numeral system with only two digits \u2014 0 and 1. Computers use binary to store data and execute calculations, which means they only use zeros and ones. In Boolean logic, a single binary digit can only represent True (1) or False (0). Any integer, in fact, can be represented in binary.<\/p>\n

Given a decimal number the task is to convert the given decimal to binary<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given number =200<\/pre>\n

Output:<\/strong><\/p>\n

The binary representation of the given number 200  : \r\n11001000<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given number =1<\/pre>\n

Output:<\/strong><\/p>\n

The binary representation of the given number 1: \r\n1<\/pre>\n

Example3:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given number =32<\/pre>\n

Output:<\/strong><\/p>\n

The binary representation of the given number 32  : \r\n100000<\/pre>\n

Python Program to Print Binary Representation of a Number<\/h2>\n

There are several ways to print the binary representation of a given decimal number some of them are:<\/p>\n