Programming with Control Structures

profileadelen
 (Not rated)
 (Not rated)
Chat

Part D: Programming with Control Structures
Develop a Python program which will calculate the sum of an integer series, as described below. The program wil repeatedly prompt he user to enter a command (a character string). The program wil
halt and display the mesage “Program halted normaly” when the command is “exit”.
When the command is “squares”, the program wil prompt he user to enter the inital integer number in
the series and then the number of terms in the series. It wil use repetion to compute the sum of the
series, and then display the results. For example, if the inital integer is 2 and the number of terms is 4:
Sum = 2^2 + 3^2 + 4^2 + 5^2 = 54
When the command is “cubes”, the program wil prompt he user to enter the inital integer number in
the series and then the number of terms in the series. It wil use repetion to compute the sum of that
series, and then display the results. For example, if the inital integer is 3 and the number of terms is 2:
Sum = 3^3+ 4^3 = 91
The program wil display the mesage “** Invalid choice **” if the user enters an invalid command.
The program wil use repetion to compute the sums (rather than using a closed form equation). After
al, the point is to practice with nest control constructs.
You may asume that he user enters integer numbers when prompted for numeric values.

    • 11 years ago
    the answer 100 % correct and works on python 2.7 and 3.4
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      the-answer.zip