To accept a no. From the user and find and print whether that no. Is an Armstrong no. Or not?
Answers
Answered by
0
Answer:
Sorry I didn't understand the question
Answered by
0
Armstrong number
Output:
Enter any number: 153
Armstrong number
Explanation:
Program:
val= int(input("Enter any number: ")) #defining variable val and input value by user
sum = 0 #defining variable sum and assign value 0
t=val #defining variable t and assign user input value
while t > 0: #defining loop to check Armstrong number
digit = t % 10 #give remainder
sum += digit ** 3 #add value
t //= 10 #give quotient
if val == sum: #check value
print("Armstrong number")
else:
print("no an Armstrong number")
Description:
- In the above code, a "val" variable is declared, which accepts an integer value from the user end.
- In the next line, two other variable "sum" and "t" is declare, in which "t" holds, user input value, and use in while loop to check value.
- Inside the loop, it calculates the Armstrong number and uses if condition to checks, and prints its value.
Learn more:
- What is Armstrong number: https://brainly.in/question/11304746
Similar questions
Math,
5 months ago
Math,
5 months ago
India Languages,
11 months ago
Hindi,
11 months ago
Computer Science,
1 year ago
Chemistry,
1 year ago