Question: Problem 3 . 4 . Errors in summation The following code is supposed to compute the sum s = PM k = 1 1 (
Problem Errors in summation
The following code is supposed to compute the sum s
PM
k
k
for M
s
M
for i in rangeM:
s k
prints
The program has three errors and therefore does not work. Find the three errors
and write a correct program. Put comments in your program to indicate what
the mistakes were.
There are two basic ways to find errors in a program:
Read the program carefully line by line, and think about the consequences
of each statement. Look for inconsistencies in the form of variables being
used before they are defined, and perform the calculations in the statements
by hand to see how variables change their value.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
