sum of 1/2+2/3+3/4+...+n/n+1

+1 vote
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 by Dhineshbabu
• 130 points
3,059 views

1 answer to this question.

+1 vote
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)))
answered Dec 27, 2019 by Nisha
• 160 points

Related Questions In Python

+3 votes
2 answers

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

answered Aug 4, 2018 in Python by Omkar
• 69,030 points

edited Aug 8, 2018 by Omkar 4,176 views
+2 votes
3 answers

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

answered Dec 8, 2019 in Python by vinaykumar
• 180 points
6,336 views
0 votes
1 answer

Create 3*4 array of random numbers - Python

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

answered May 24, 2019 in Python by Umer
75 views
0 votes
1 answer

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

answered May 24, 2019 in Python by Radhika
79 views
0 votes
1 answer

Install pip in Python 3.4

Don't worry! Python already comes in default ...READ MORE

answered May 1, 2018 in Python by aayushi
• 750 points
604 views
0 votes
1 answer

What is the meaning of “int(a[::-1])” in Python?

Assumming a is a string. The Slice ...READ MORE

answered Aug 27, 2018 in Python by Priyaj
• 57,640 points
189 views
0 votes
1 answer

How is Python 2.7.3 and Python 3.3 different?

raw_input() is not used in Python 3. Use input()  ...READ MORE

answered Sep 12, 2018 in Python by SDeb
• 13,250 points
123 views
0 votes
1 answer

Python 3 equivalent of SimpleHTTPServer

The SimpleHTTPServer module has been merged into ...READ MORE

answered Nov 20, 2018 in Python by SDeb
• 13,250 points
206 views
0 votes
1 answer

sys.argv[1] what is the meaning of it?

sys.argv[1] contains the first command line argument passed to your script. For ...READ MORE

answered Dec 17, 2018 in Python by abc
3,268 views
0 votes
1 answer

Need help installing easy_install in Python 2.7.1 on Windows 7

That tool is part of the setuptools ...READ MORE

answered Dec 26, 2018 in Python by Nymeria
• 3,520 points
210 views