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

while loop

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

while loop

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

##i =1

##while i<=10:
## print(i,end =" ")
## i +=1

##n =int(input("enter the no:"))


##i=1
##total=0
##while i <=n:
## total +=i
## i +=1
##print("the sum of",n,"is",total)

##n= int(input("enter the no:"))


##i=2
##while i<=n:
## print(i)
## i +=2

##n= int(input("enter the no:"))


##fact =1
##i =1
##while i<=n:
## fact*=i
## i+=1 #--->>if we print(fact) then loop 1,2,6,24,120#each no ka factorial
will give.
##print("factorial of ",n, "is",fact) #this gives simply the ans.

##num= int(input("enter the no:"))


##reversed_num =0
##while num>0:
## remainder= num%10
## reversed_num =reversed_num *10+remainder
## nun//=10 #closing walah otherwise infinite loop.
## print(reversed_num)

##num=int(input("enter the no:"))


##sum_digit =0
##while num>0:
## sum_digit += num%10
## num //=10
##print("The sum of digits of " sum_digit)

##import random
##target =random.randint(1,100)
##guess =None
##while guess !=target:
## guess =int(input("guess the number(1-100):"))
## if guess<target:
## print("too low!")
## elif guess >target:
## print("too high!")
## else:
## print("you guessed it!")

##N=int(input("enter the no:"))


##i=1
##while i<=10:
## print(N,'*',i,'=',N*i)
## i +=1

##num=int(input("enter the no:"))


##original_num =num
##reversed_num =0
##while num>0:
## remainder =num%10
## reversed_num =reversed_num*10+remainder
## num//=10
##if original_num==reversed_num:
## print("the no is palindrome")
##else:
## print("The number is not palindrome")

##n=int(input("enter the no"))


##while n>0:
## print(n)
## n-=1

##N=int(input("enter the no of terms:"))


##a,b=0,1
##i=1
##while i<=N:
## print(a,"\n")
## a,b=b,b+a
## i+=1

##num=int(input("enter a number"))
##count=0
##while num>0:
## num//=10
## count+=1
##print("Number of digits:",count)

##num= int(input("enter a number:"))


##largest_digit =0
##while num>0:
## digit = num%10
## if digit>largest_digit:
## largest_digit =digit
## num//=10
##print("largest digit is:",largest_digit)

##a = int (input("enter the first no:"))


##b = int (input ("enter the secondno:"))
##while b:
## a,b =b, a%b
##print("hcf is :",a)
##
##a= int(input("enter the forst no:"))
##b= int (input("enter the second no:"))
##def hcf(x,y):
## while y:
## x,y =y,x%y
## return x
##lcm=(a*b)//hcf(a,b)
##print("lcm is :",lcm)

##num=int(input("enter the no:"))


##i =2
##is_prime= True
##while i<=num//2:
## if num%i ==0:
## is_prime =False
## break
## i +=1
##if is_prime and num>1:
## print(num,"is a prime number.")
##else:
## print(num,"is not a prime number .")
##

num=int(input("enter the number:"))


digit_to_count =int(input("enter the digit to count"))
count=0
while num>0:
digit = num%10
if digit == digit_to_count:
count+=1
num//=10
print(digit_to_count,"apperas",count,"times")

You might also like