4.9 Code Practice: Question 1 [Intructions shown]


Instructions:

Write code using the range function to add up the series 3, 6, 9, 12, 15, ..... 66 and print the resulting sum.


Expected Output

759

49 Code Practice Question 1 Intructions shownInstructionsWrite code using the range function to add up the series 3 6 9 12 15 66 and print the resulting sumExpe class=

Respuesta :

In python:

total = 0

for x in range(3, 67, 3):

   total += x

print(total)

I hope this helps!

fichoh

The required program written in python 3 which sums the values in the series given with a common difference of 3 is :

sum = 0

#initialize a variable which holds the sum of the series to 0

for num in range(3, 69 ,3):

#use a for loop to pick each value in the series using the range function

sum+=num

#for each number picked, add the value to the initialized sum variable

print(sum)

#display the resulting sum

  • The third argument in the range function is the amount of step the loop takes, which corresponds to the common difference of the series.

Therefore, the resulting output of the program is attached below.

Learn more :https://brainly.com/question/18768438

Ver imagen fichoh
ACCESS MORE
EDU ACCESS