asked 183k views
4 votes
2: Design an algorithm which generates even numbers between 1000 and 2000 and then prints them in the standard output. It should also print total sum​

1 Answer

1 vote

def main():

even_numbers = []

for i in range(1000, 2001):

if i % 2 == 0:

even_numbers.append(i)

total_sum = sum(even_numbers)

print("Even numbers between 1000 and 2000:")

print(even_numbers)

print("Total sum:", total_sum)

if __name__ == "__main__":

main()

answered
User Mikkom
by
8.0k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.