Answer to Question #307807 in Python for jamil

Question #307807

6. Write a Python program that reads a number and finds the sum of the series of 1 +11 + 111 + 1111 + ….+N terms. 

===================================================== 

Sample Input1

Sample Output1: 

1 + 11 + 111 + 1111 + 11111 

The Sum is: 1234




1
Expert's answer
2022-03-10T02:08:36-0500
n = int(input("Enter number N: "))
print()
sum = 0
str = ''
for i in range(n):
    str = str + '1'
    sum = sum + int(str)
print(f'Sum: {sum}')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS