Program to input the value of x and n and print the sum of series ?+?^?/?!−?^?/?!+?^?/?!…?^?/?!
#pythonpractical #computerscience #cbseclass11
In this video, I have covered up the practical 5.4 of CBSE Class 11 Computer Science with Python. Write a program to input the value of x and n and print the sum of the following series: ?+?^?/?!−?^?/?!+?^?/?!…?^?/?!
I have described 2 different methods that can be used for the problem with their programming codes.
Method 1:
#Write a program to input the value of x and n and print the sum of the following series:
#x+x^2/2!-x^3/3!+x^4/4!+ ............x^n/n!
print(" Write a program to input the value of x and n and print the sum of the \n")
print(" following series: x+x^2/2!-x^3/3!+x^4/4!+ ............x^n/n! \n")
x = int(input("Enter value of x:"))
n=int(input("Enter value of n:"))
s=x
j=1
fact=1
if (n==1):
print(" Sum of the series: x+x^2/2!-x^3/3!+x^4/4!+ ............x^n/n! \n")
print(" with x:",x,"and n:",n,"is=",s)
else:
for i in range(2,n+1):
fact=fact*i
j=(-1)**i
k=((j*(x**i))/fact)
s=s+k
print(" Sum of the series: x+x^2/2!-x^3/3!+x^4/4!+ ............x^n/n! \n")
print(" with x:",x,"and n:",n,"is=",s)
Method 2:
#Write a program to input the value of x and n and print the sum of the following series:
#x+x^2!/2-x^3/3!+x^4/4!+ ............x^n/n!
import math
print(" Write a program to input the value of x and n and print the sum of the \n")
print(" following series: x+x^2/2!-x^3/3!+x^4/4!+ ............x^n/n! \n")
x = int(input("Enter value of x:"))
n=int(input("Enter value of n:"))
s=x
j=1
fact=1
if n==1:
print(" Sum of the series: x+x^2/2!-x^3/3!+x^4/4!+ ............x^n/n! \n")
print(" with x:",x,"and n:",n,"is=",s)
else:
for i in range(2,n+1):
fact=fact*i
j=math.pow(-1,i) #(-1)**i
k=math.pow(x,i) #x**i
k=((k*j)/fact)
s+=k
print(" Sum of the series: x+x^2/2!-x^3/3!+x^4/4!+ ............x^n/n! \n")
print(" with x:",x,"and n:",n,"is=",s)
To learn python full course watch: https://www.youtube.com/watch?v=-
eZ9aGK4NmY&list=PLuND5JsayY-xzEYTExVVsHSnV3RyU7_Og To learn
Class XI Computer Science: https://www.youtube.com/watch?v=6QVBMuWIBrk&list=PLuND5JsayY-ypqFFFqQyD_H5y5MdIflMc
if you want video on any particular topic you can comment or contact.
fb page : https://www.facebook.com/computerguruhub/
Author on fb: https://www.facebook.com/sknager
Telegram Channel: https://t.me/computerguruhub
Telegram Group: https://t.me/computerguruhub1
#computerscience #cbse #computerscienceclass11 #python #class11computerscience #pythonprogramming #cbsepythonclass11 #pythonclass11 #class11 #class11pythoninhindi #pythonclass12 #class11python #pythonforclass11 #pythontutorial #advantagesofpython
#csforclass11 #codipymohit #pythonpracticalprogramming #ipforclass11 #practical #class11pythonchapter1 #pythontutorialforbeginners #cbsepythonboardexampapers #class12pythoninhindi #completepythoncourse #cs #xi #cbseclass11computerscience
#computerscienceclass11cbse #sumitaaroraclass11 #pythoninhindi #class11pythoncbse #computerscienceforclass11 #pythonforbeginners #pythonclass11cbse #classxi #sumitkumarnager #computerguruhub
Видео Program to input the value of x and n and print the sum of series ?+?^?/?!−?^?/?!+?^?/?!…?^?/?! автора Кодовая Дуальность
Видео Program to input the value of x and n and print the sum of series ?+?^?/?!−?^?/?!+?^?/?!…?^?/?! автора Кодовая Дуальность
Информация
2 декабря 2023 г. 11:52:36
00:14:08
Похожие видео