Skip to main content

To find whether it is an Armstrong number or not using Python program

Armstrong Number

num = int(input("Enter a number: "))
sum = 0
temp = num
while temp > 0:
   digit = temp % 10
   sum += digit ** 3
   temp //= 10

if num == sum:
   print(num,"is an Armstrong number")
else:

   print(num,"is not an Armstrong number")


Output:
Enter a number: 555

555 is not an Armstrong number

Comments

Popular posts from this blog

Program to check whether the given number is prime or not

#include<stdio.h> #include<conio.h> void main() {   int n, i, count=0;   clrscr();   printf("\nEnter a number: ");   scanf("%d",&n);   for(i=2;i<=n/2;i++)   {     if(n%i==0)     {       count++;       break;     }   }   if(count==0)   {      printf("%d is a prime number",n);   }   else   {      printf("%d is not a prime number",n);   }   getch(); } OUTPUT: Enter a number: 11 11 is a prime number Enter a number: 25 25 is not a prime number

Addition and Subtraction of two Matrices

/*Program to Find the Addition and Subtraction of two Matrices*/ #include<stdio.h> #include<conio.h> #include<math.h> void main() {    int a[10][10], b[10][10], c[10][10];    int i,j,n,m;    clrscr();    printf("\n\tAddition and Subtraction of two matrices");    printf("\nEnter the no. of rows and columns:");    scanf("%d%d",&m,&n);    printf("\nEnter the first matrix:\n");    for(i=0;i<m;i++)    {      for(j=0;j<n;j++)      { scanf("%d",&a[i][j]);      }    }    printf("\nEnter the first matrix:\n");    for(i=0;i<m;i++)    {      for(j=0;j<n;j++)      { scanf("%d",&b[i][j]);      }    }    printf("\nAddition of two matrices:\n");    for(i=0;i<m;i++)   ...

Star Design using Python program

Star Design import turtle turObj = turtle.Turtle() turObj.getscreen().bgcolor("#555555") turObj.speed(10) def star(turtle, size):     if size <=10:         return     else:         for i in range(30):             turObj.color("#FEACFF")             turObj.forward(i * 15)             turObj.right(144)            star(turObj,100)        turtle.done() Output: