What is the python logic to check if a number is armstrong number or not

0 votes
How is the logic different from any other programming language?
Jul 23, 2019 in Python by Waseem
• 4,540 points
1,840 views

2 answers to this question.

–1 vote
number = int(input("enter a number"))

s = 0
temp = number
while temp > 0:
     c = temp % 10
     s += c**3
     temp //= 10
if temp ==  num:
   print('armstron number')
else:
   print('not an armstrong number')  
answered Jul 30, 2019 by Mohammad
• 3,230 points
0 votes
a = int (input('enter number'))
num = a
sum = 0
while a!= 0 :
    x = a%10
    sum = sum + (x*x*x)
    a = a//10
if sum == num:
    print ('YES IT\'s an AMSTRONG NUMBER')
else :
    print('IT\'s NOT AN AMSTRONG NUMBER')
answered Jul 16, 2020 by amrut
• 240 points

Related Questions In Python

0 votes
1 answer

What is the Python logic to count the number of capital letters in a file?

Hi, You can use this piece of code, ...READ MORE

answered Jun 26, 2020 in Python by Roshni
• 10,480 points
2,195 views
0 votes
2 answers

Check a number is Prime or not in Python

There is an efficient way to write ...READ MORE

answered Oct 26, 2018 in Python by Priyaj
• 58,020 points
5,146 views
0 votes
1 answer

How to print a message or the error if a file is not found?

To print the message that file is not ...READ MORE

answered Jan 2, 2019 in Python by Omkar
• 69,220 points
2,925 views
0 votes
1 answer

How do I check if input string is a valid regular expression or not in Python?

Hi. Good question! Well, just like what ...READ MORE

answered Feb 12, 2019 in Python by Nymeria
• 3,560 points
11,335 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,486 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,150 views
0 votes
1 answer

What is the logic to check if a number is prime or not in python?

n = int (input ('ENTER NUMBER TO ...READ MORE

answered Jul 16, 2020 in Python by amrut
• 240 points
1,091 views
+1 vote
2 answers

how can i do a binary search in python?

def Binary_search (array , element):       ...READ MORE

answered Jul 10, 2020 in Python by anonymous
• 240 points
1,132 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP