CALCULATING ARMSTRONG NUMBER IN PYTHON LANGUAGE

Code:-

 while True:

    """128649
    1^6+2^6+8^6+6^6....
    """
    a = input("FIRST LET ME KNOW THE NUMBER WHAT IS IT? : ")
    power = len(a)
    li = []
    if a == "quit".lower():
        quit()
    #print(power)
    for i in a:
        e = int(i)**power
        li.append(e)
    #print(li)
    #print(sum(li))
    if sum(li) == int(a):
        print(f"{a} is an armstrong number.")
    else:
        print(f"{a} is not an armstrong number.")
while True:
    """128649
    1^6+2^6+8^6+6^6....
    """
    a = input("FIRST LET ME KNOW THE NUMBER WHAT IS IT? : ")
    power = len(a)
    li = []
    if a == "quit".lower():
        quit()
    #print(power)
    for i in a:
        e = int(i)**power
        li.append(e)
    #print(li)
    #print(sum(li))
    if sum(li) == int(a):
        print(f"{a} is an armstrong number.")
    else:
        print(f"{a} is not an armstrong number.")

Comments

  1. Thanks for giving such information, I read many blogs but did not get such information. I have also written something about Python, must read it onceHIre Python Developers From India

    ReplyDelete

Post a Comment

Popular posts from this blog

MY FIRST MYSQL PROJECT I EVER MADE

Automating Piano Tiles in Python Which is Damn easy!!!!!!!!

A SIMPLE GAME FOR A BEGINNER IN PYTHON WITH ONLY TWO MODULES