{"id":19149,"date":"2021-08-29T15:13:39","date_gmt":"2021-08-29T09:43:39","guid":{"rendered":"https:\/\/python-programs.com\/?p=19149"},"modified":"2021-11-22T18:37:08","modified_gmt":"2021-11-22T13:07:08","slug":"python-program-to-find-out-how-many-1-and-0-in-a-given-number","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-out-how-many-1-and-0-in-a-given-number\/","title":{"rendered":"Python Program to Find out How many 1 and 0 in a Given Number"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Enter Basic Salary and Calculate Gross Salary of an Employee<\/a>
\nGiven a Number and the task is to calculate the count of 1’s and 0’s in a given Number in Python.<\/p>\n

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

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

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

Given Number = 111000101<\/pre>\n

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

The Count of 0's in a given number =  4\r\nThe Count of 1's in a given number =  5<\/pre>\n

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

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

Given Number = 1010101110000<\/pre>\n

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

The Count of 0's in a given number =  7\r\nThe Count of 1's in a given number =  6<\/pre>\n

Program to Find out How many 1 and 0 in a Given Number In Python<\/h2>\n

Below are the ways to calculate the count of 1’s and 0’s in a given Number:<\/p>\n