Question: Write a Python program that calculates the sum of the first N of even numbers, where N is a positive integer entered by the user.

Write a Python program that calculates the sum of the first N of even numbers, where N is a
positive integer entered by the user. Ensure that only positive (natural numbers) integer values
are accepted. Use a for loop to iterate from 1 to N inclusively, and calculate the running total of
even numbers.
After calculating the sum, print the total sum of the first N even numbers.
Submit your Python script (*.py) on CodeGrade named: SU4_2.py
Example:
If the user enters N =4, the program should calculate the sum as 2+4+6+8=20, and print the
result as The sum of the first 4 even numbers is 20. Use f-string formatting to print the output.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!