“Armstrong Python” Code-Antworten

Armstrong -Nummer Python

a = 1634
aa = str(a)
lenn = len(aa)
count = 0
for i in range(lenn):
    count +=  int(aa[i]) ** 4
if count == a :
    print("Yes")
else:
    print('No')
Kumaran KM

Python Armstrong -Nummer

number = 153
temp = number
add_sum = 0
while temp!=0:
    k = temp%10
    add_sum +=k*k*k
    temp = temp//10
if add_sum==number:
    print('Armstrong Number')
else:
    print('Not a Armstrong Number')
codelearner

Armstrong Python

def check_if_armstrong():
    number = input("Enter number: ")
    
    sum_of_cube = 0
    for i in range(len(number)):
        sum_of_cube = sum_of_cube + pow(int(number[i]), 3)
    print(sum_of_cube)
    
    if int(number) == sum_of_cube:
        print(f'{number} is armstrong')
    else:
        print(f'{number} isn\'t armstrong')
        
check_if_armstrong()
Suraj Kr Thapa

Ähnliche Antworten wie “Armstrong Python”

Fragen ähnlich wie “Armstrong Python”

Weitere verwandte Antworten zu “Armstrong Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen