Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python (You can use for, while, if, else, elif) (Do Not use class, keep it simple) Calculating sum of series is an important concept.

Using Python (You can use for, while, if, else, elif) (Do Not use class, keep it simple)

Calculating sum of series is an important concept. We like to write a SIMPLE program to solve the following sum.

image text in transcribed

Dont let the math scare you! This is just a loop that starts from 1 and goes up to n. We simply add the terms (k+1)/k. Written in the long form; it looks like:

s = 2/1 + 3/2 + 4/3 + (n+1)

as an example, when n = 5, we get s = 2/1 + 3/2 + 4/3 + 5/4 + 6/5 = 7.2833

a) Ask the user for a value for n

b) Validate the value of n to make sure its 1 or more. Give the user 3 tries to get it right. If the number is invalid after 3 tries, set s = -1

c) Display each of the values of k and k+1 as shown in the sample run.

d) Display the value of s with 4 digits after the decimal point

Sample interaction 1:

Enter a value for the final value of the series: -900

Invalid input: Enter a value for the final value of the series: 0

Invalid input: Enter a value for the final value of the series: 5

Enter a value for the final value of the series: 5 2 / 1 + 3 / 2 + 4 / 3 + 5 / 4 + 6 / 5 = 7.2833

n S K (k+ 1)/k k=1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions