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

Creating a Realtime Clock using Python program

Clock from turtle import * from datetime import datetime def jump(distanz, winkel=0):     penup()     right(winkel)     forward(distanz)     left(winkel)     pendown() def hand(laenge, spitze):     fd(laenge*1.15)     rt(90)     fd(spitze/2.0)     lt(120)     fd(spitze)     lt(120)     fd(spitze)     lt(120)     fd(spitze/2.0) def make_hand_shape(name, laenge, spitze):     reset()     jump(-laenge*0.15)     begin_poly()     hand(laenge, spitze)     end_poly()     hand_form = get_poly()     register_shape(name, hand_form) def clockface(radius):     reset()     pensize(7)     for i in range(60):         jump(radius)         if i % 5 == 0:           ...

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

Inserting,Deleting and Updating table values in Database using Python Programming

Insert,Delete and Update import tkinter as tk from tkinter import * import mysql.connector import datetime def IsValidDate(InputDate):     day = InputDate[:2]     month = InputDate[3:5]     year = InputDate[6:]         IsValid = True         try :         datetime.datetime(int(year),int(month),int(day))     except ValueError :         IsValid = False     return IsValid def FormatDBDate(InputDate):     dt = InputDate[6:] + "-" + InputDate[3:5] + "-" + InputDate[:2]     return dt    def FormatEDDate(InputDate):     dt =  InputDate[8:] + "/" + InputDate[5:7] + "/" + InputDate[:4]     return dt  def DeleteEmployee(id, eid, ename, dob, doj, adr, cty, pcd, mob, eml, gen, dep):     conn=mysql.connector.connect(user='root',password='harsha',host='localhost', datab...