QUESTION - DISPLAY THE WEIGHTED SUM
Write a program which, given a four digit number, displays the weighted sum of the number. The
weighted sum of a number is the total of multiplying each digit by its position in the number (counting from the left and starting from 1). For example, given the four digit number 2756 we calculatethewei ghtedsumofdigit sas: 2*1+7*2+5*3+6*4 whichequals55.
Paste the following statement into your program.
number = 1742 #Make changes to this number to test you program
The program prints the four digit number followed by "Weighted Sum: " followed by the weighted sum.
For example: 1742 Weighted sum: 35
Write a program which, given a four digit number, displays the weighted sum of the number. The
weighted sum of a number is the total of multiplying each digit by its position in the number (counting from the left and starting from 1). For example, given the four digit number 2756 we calculatethewei ghtedsumofdigit sas: 2*1+7*2+5*3+6*4 whichequals55.
Paste the following statement into your program.
number = 1742 #Make changes to this number to test you program
The program prints the four digit number followed by "Weighted Sum: " followed by the weighted sum.
For example: 1742 Weighted sum: 35
Comment