0% found this document useful (0 votes)
3 views

Lab Program 4

The document describes a Python program that reads a multi-digit number and calculates the frequency of each digit. It processes each digit by dividing the number and counting occurrences. The output displays the digit alongside its frequency in a formatted manner.

Uploaded by

mohammedarham760
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lab Program 4

The document describes a Python program that reads a multi-digit number and calculates the frequency of each digit. It processes each digit by dividing the number and counting occurrences. The output displays the digit alongside its frequency in a formatted manner.

Uploaded by

mohammedarham760
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Python Programming Lab

Program-4:
Read a multi-digit number (as chars) from the console. Develop a program to print
the frequency of each digit with suitable message.

number=int(input("Enter any Number"))


print("Digit\tFrequency")
for i in range(0,10):
count=0;
temp=number;
while temp>0:
digit=temp%10
if digit==i:
count=count+1
temp=temp//10;

if count>0:
print(i,"\t",count)

Explanation:
1. The program reads multi digit number. (i.e. 234512, 3424567, 892313..)
2. It then divide the number by 10 to process individual digit.
3. Then it will check its appearance that how many times it appears in the given number.

Output – 1:
Enter any Number 234523
Digit Frequency
2 2
3 2
4 1
5 1

Output – 2:
Enter any Number 352453
Digit Frequency
2 1
3 2
4 1
5 2

You might also like