😎Hey, thanks for watching! We’d love to know your thoughts/doubts here in the comments. 👉For professional self-paced certification courses (pre-recorded), visit: bit.ly/Pre-Recorded-Course 👉Don’t forget to SUBSCRIBE to our channel for more such videos & valuable content: bit.ly/TH-cam-WsCubeTech
def armstrong_number(number): alpha=sum(int(item)**len(str(number))for item in str(number)) return alpha def armstrong_sum_in_an_interval(a,b): armstrong_number_int = [] for i in range(a,b+1): if armstrong_number(i) == i: armstrong_number_int.append(i) return(armstrong_number_int) # case for finding in interval (25,134) print(f"armstrong in given interval is:{armstrong_sum_in_an_interval(25,154)}")
The above code is not well structured , use this: def is_armstrong(number): num_str = str(number) num_digits = len(num_str) armstrong_sum = sum(int(digit) ** num_digits for digit in num_str) return armstrong_sum == number def print_armstrong_numbers_in_range(start, end): print(f"Armstrong numbers between {start} and {end}:") for num in range(start, end + 1): if is_armstrong(num): print(num) start_range = int(input("Enter the start of the range: ")) end_range = int(input("Enter the end of the range: ")) print_armstrong_numbers_in_range(start_range, end_range)
m getting the outputs like 125, 153 ,216, 371, 729 for same code lower = int(input('Enter the lower limit:')) upper = int(input('Enter the upper limit:')) for num in range(lower, upper+1): order = len(str(num)) sum = 0 temp = num while temp>0: digit = temp%10 sum = sum+digit**order temp//=10 if num == sum: print(num)
😎Hey, thanks for watching! We’d love to know your thoughts/doubts here in the comments.
👉For professional self-paced certification courses (pre-recorded), visit: bit.ly/Pre-Recorded-Course
👉Don’t forget to SUBSCRIBE to our channel for more such videos & valuable content: bit.ly/TH-cam-WsCubeTech
def armstrong_number(number):
alpha=sum(int(item)**len(str(number))for item in str(number))
return alpha
def armstrong_sum_in_an_interval(a,b):
armstrong_number_int = []
for i in range(a,b+1):
if armstrong_number(i) == i:
armstrong_number_int.append(i)
return(armstrong_number_int)
# case for finding in interval (25,134)
print(f"armstrong in given interval is:{armstrong_sum_in_an_interval(25,154)}")
but what if the range is from 1 to 1000 , its showing 1 to 9 in the output?
Thank you so much for this video 📸
Ver Helpful........Thanks for sharing....big like 43
Mam but 1 to upper print kar rahe hai tou tou 1 to 9 bhi print hu rahe hai but 1 to 9 is not an Armstrong number??
The above code is not well structured , use this:
def is_armstrong(number):
num_str = str(number)
num_digits = len(num_str)
armstrong_sum = sum(int(digit) ** num_digits for digit in num_str)
return armstrong_sum == number
def print_armstrong_numbers_in_range(start, end):
print(f"Armstrong numbers between {start} and {end}:")
for num in range(start, end + 1):
if is_armstrong(num):
print(num)
start_range = int(input("Enter the start of the range: "))
end_range = int(input("Enter the end of the range: "))
print_armstrong_numbers_in_range(start_range, end_range)
One to nine are also called armstrong numbers dude
@@rehanclasher115 Yes brother you are right 👍
Nice video Dedi
Sir payload ko phone m kaise copy kre
Sir devops ke lie video bnao from bigning
Mam python me ek function ke aunder kitne function define kar sakate hai please tell me
Mam bataye please
1 is armstrong number or not?
m getting the outputs like 125, 153 ,216, 371, 729 for same code
lower = int(input('Enter the lower limit:'))
upper = int(input('Enter the upper limit:'))
for num in range(lower, upper+1):
order = len(str(num))
sum = 0
temp = num
while temp>0:
digit = temp%10
sum = sum+digit**order
temp//=10
if num == sum:
print(num)
First like me bro
💅💅💅💅💅💅💅💅💅
Kachra h. Bro
Thik bujhlam na didi