Write a program to compute 1/2+2/3+3/4+...+n/n+1 with a given n input by console (n>0).

Example: If the following n is given as input to the program: 5

Then, the output of the program should be: 3.55
Dec 21, 2019 in Python 12,514 views

## 2 answers to this question.

num = int(input("Enter a number: "))
newnum = 0

for each in range(1,num+1):
newnum = newnum+(each/(each+1))

print("computed value : ",format(round(newnum,2)))
• 200 points
Nisha,

Can You please explain, how it works ?

how come 3.55 is coming up ?

Komal S Patel

+447534288877
Hey, @Komal,

While executing this code I am getting the exact output that is required. If you are facing any error please post that.
This prog. is right and in last format you can write and not that doesn't make any change.
–1 vote
n=int(input("Enter the number of terms: "))

sum=0

for i in range(1,n+1):
sum=sum+(i/(i+1))

print("The sum of series is: ",round(sum,2))
answered Sep 28, 2020 by anonymous
• 140 points

## What will be the output of below code and why? x=[1,2,3,4,5] print(x.insert(2,3))

If you write x.insert(2,3) and then print x ...READ MORE

## how to print array integer without [] bracket in python like result = 1,2,3,4,5

Hey @abhijmr.143, you can print array integers ...READ MORE

## Write a for loop that prints all elements of a list and their position in the list. a = [4,7,3,2,5,9]

Try using this question by list comprehension: a=[4,7,3,2,5,9] print([x for ...READ MORE

## what is the output of m = np.array([2,4,6]) n = np.array([2, True, False]) print(m+n)

Hi. @Nandini, The above code will give you ...READ MORE

## Create 3*4 array of random numbers - Python

To create different arrays like random arrays:  np.random.rand(3,4) ...READ MORE

## How do I create 3 X 4 array of random numbers between 0 and 100 using python?

Use numpy in the following manner: np.random.rand(3,4)*100 When you ...READ MORE

## Sum of prime numbers from m to n in python

def is_prime(number):     if number < 2:         return False     for i ...READ MORE