Answer to Question #221174 in Python for Hari nadh babu

Question #221174

Sum of the series


This Program name is Sum of the series. Write a Python program to Sum of the series, it has two test cases


The below link contains Sum of the series question, explanation and test cases


https://drive.google.com/file/d/15oYX0I0vkskebiNz7Wg80SdkZ-MzHTrg/view?usp=sharing


We need exact output when the code was run

1
Expert's answer
2021-08-02T15:56:57-0400
X = int(input('Enter integer here: '))
N = int(input('Enter integer here: '))
M = 1 + 2*(N-1)
list1 = []
i = 1
j = 0
k = 0
while i <= M:
  list1.append(X**i)
  i = i + 2


for s in list1:
  if (list1.index(s))%2 == 0:
    j = j + s
  else:
    k = k - s
print(j+k)

Enter integer here: 2
Enter integer here: 5
410

Enter integer here: 3
Enter integer here: 2
-24

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