WAP to print the even numbers within 51.Display the numbers and their
sum. [5]
Q4) WAP to input a number and find how many factors it has.
Answers
Answered by
1
# even numbers from 2 to 51
even_nums = [n for n in range(2, 50 + 1) if n % 2 == 0]
print('\n'.join(map(str, even_nums)), f"\nsum even_nums: {sum(even_nums)}")
# find factors of a num
num = int(input("enter a num: "))
factors = [n for n in range(1, num + 1) if num % n == 0]
print(f"factors: {len(factors)}")
Similar questions