No products in the cart.

Write the python program to input …

CBSE, JEE, NEET, CUET

CBSE, JEE, NEET, CUET

Question Bank, Mock Tests, Exam Papers

NCERT Solutions, Sample Papers, Notes, Videos

Write the python program to input the value of x and n and print the sun of the series: 1-x+x²-x³+x⁴.........x to the power n.
  • 5 answers

Har Har Mahadev 🙏 3 years, 10 months ago

Thanks

First Name 3 years, 10 months ago

Indentation didn't came . Writing again from for loop :
s=1
for i in range (1,n+1):
⠀⠀⠀s=s+ sign*x**i
⠀⠀⠀s*= -1<br print("The sum of series is",s)

First Name 3 years, 10 months ago

sign*=-1 will come instead of s

First Name 3 years, 10 months ago

x = int(input("Enter the value of x : "))
n = int(input("Enter the value of n : "))
sign= -1
s=1 for i in range(1,n+1): ⠀⠀⠀s=s+ sign*x**i
⠀⠀⠀s*= -1
print("The sum os the series is", s)

Har Har Mahadev 🙏 3 years, 10 months ago

Print the sum not sun !
http://mycbseguide.com/examin8/

Related Questions

Write a program for swapping two numbers?
  • 0 answers
Write a program for swapping two numbers
  • 1 answers
Define packages
  • 0 answers
What is alu
  • 1 answers

myCBSEguide App

myCBSEguide

Trusted by 1 Crore+ Students

Test Generator

Test Generator

Create papers online. It's FREE.

CUET Mock Tests

CUET Mock Tests

75,000+ questions to practice only on myCBSEguide app

Download myCBSEguide App