Python Special Programs - Armstrong Number

preview_player
Показать описание
Python Programming: Python Special Programs - Armstrong Number
Topics discussed:
1. Python Program to print the Armstrong Number.

Music:
Axol x Alex Skrindo - You [NCS Release]

#PythonByNeso #PythonProgramming #PythonPrograms
Рекомендации по теме
Комментарии
Автор

Alternate code:
n=input()
sum=0
for i in n:
sum+=int(i)**len(n)
if(sum==int(n)):
print("yes")
else:
print("no")

dhirajsarkar
Автор

Alternative code :

n=input("enter your number : ")
sum=0
for i in range(len(n)):
r=int(n[i])**len(n)
sum+=r

if (int(n)==sum):
print("it's an armstrong number")
else:
print("not an armstrong number")

banibratamanna
Автор

Code for checking a armstrong number for n digit number: num=int(input("Enter the numbers:"))
sum=0
degree=len(str(num))
temp=num
while temp>0:
digit=temp%10
sum+=digit**degree
temp//=10
if num==sum:
print(f"{num} is an amstrong number")
else:
print(f"{num} is not an amstrong number")

NivyaGovindarajj
Автор

Bro, Please Do A Playlist On Machine Learning That Have
1) Concepts
2) Diagram
3) Examples
4) Python Programs
5) Related Concepts

suryabala_
Автор

Pro Tip: Try to make the program by yourself first

user = input('Koi number input karo : ')
n = len(user)
arms = 0
user = (int(user))
temp = user
while (temp != 0):
rem = temp % 10
arms += rem ** n
temp = temp // 10 # '//' performs integer division

if user == arms:
print ('Armstrong number!')
else:
print('Not an Armstrong Number!')

tayyab.sheikh
Автор

E-> E+E|E-E| id output id-id*id Ambiguity in cfg problem sol the rightmost derivation nd ieft most derivation

KeyaAngel
Автор

Next Boyer-Moore Algorithm with bad character heuristic.

mohammadfirozahmmed
Автор

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

if (num == sum):
print(f"{num} is an Armstrong number")
else:
print(f"{num} is not an Armstrong number")

OUTPUT:-
Enter a n-digit number : 1234
1234 is not an Armstrong number

Enter a n-digit number : 153
153 is an Armstrong number

ashishbansal