“Armstrong Python” Kode Jawaban

Armstrong Number 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

Nomor Python Armstrong

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

Jawaban yang mirip dengan “Armstrong Python”

Pertanyaan yang mirip dengan “Armstrong Python”

Lebih banyak jawaban terkait untuk “Armstrong Python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya