Ответы
Here is a Python program that can find all even numbers from 0 to n (input from keyboard), all odd numbers from 0 to n, and the sum of all odd numbers from 1 to n (input from keyboard):
n = int(input("Please enter a positive integer: "))
# Find all even numbers from 0 to n
even_list = []
for i in range(0, n+1):
if (i % 2 == 0):
even_list.append(i)
# Find all odd numbers from 0 to n
odd_list = []
for i in range(0, n+1):
if (i % 2 != 0):
odd_list.append(i)
# Calculate the sum of all odd numbers from 1 to n
sum_of_odd = 0
for i in range(1, n+1):
if (i % 2 != 0):
sum_of_odd += i
# Print the results
print("Even numbers from 0 to " + str(n) + " are: " + str(even_list))
print("Odd numbers from 0 to " + str(n) + " are: " + str(odd_list))
print("Sum of all odd numbers from 1 to " + str(n) + " is: " + str(sum_of_odd))
If something is wrong, write in the comments, I will correct the answer
Have a nice evening!!!