Professional Documents
Culture Documents
Subhojit Ghosh Class XI (Science) Roll No 115
Subhojit Ghosh Class XI (Science) Roll No 115
Laboratory File
3 Write a Program to Print table of Given number. (User Will enter the 5
number)
Sr Programs Page
.No Number
# 1. Write a Program to check whether the user is eligible for Driving License.
if (age>=18):
else:
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
>>>
>>>
# 2. Write a Program to calculate the sum of following series 1+ (1+2) + (1+2+3) +…………..+(1+2+3+…..+n)
sum=0
for a in range(2,(n+2)):
term=0
for b in range(1,a):
term+=b
print("Term",(a-1),":",term)
sum+=term
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
>>>
Term 1 : 1
Term 2 : 3
Term 3 : 6
Term 4 : 10
Term 5 : 15
Sum of 5 terms is 35
>>>
#3. Write a Program to Print table of Given number. (User Will enter the number)
for i in range(1,11):
print(n,"*",i," = ",(n*i))
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
>>>
6*1=6
6 * 2 = 12
6 * 3 = 18
6 * 4 = 24
6 * 5 = 30
6 * 6 = 36
6 * 7 = 42
6 * 8 = 48
6 * 9 = 54
6 * 10 = 60
>>>
#4. Write a Program to generate the sequence : -5,10,-15,20,..........upto n , where n is an integer entered by
the user
sign=-1
for i in range(5,n,5):
term=i*sign
sign=sign*(-1)
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
>>>
-5,10,-15,20,-25,30,-35,40,-45,
>>>
# 5. Write a Program to check whether a number is palindrome or not.
temp=n
rev=0
while temp>0:
digit=temp%10
rev=(rev*10)+digit
temp//=10
if n==rev:
else:
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
>>>
>>>
#6. Write a Program to check whether a number is an Armstrong or not.
temp=n
rev=0
while temp>0:
digit=temp%10
rev= rev+(digit**3)
temp//=10
if n==rev:
else:
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
>>>
>>>
# 7. Write a Program to input a number and calculate its double factorial.
fact = 1
for i in range(n,0,-2):
fact*=i
print(n,"!! is :",fact)
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
>>>
7 !! is : 105
>>>
#8. Write a Program to print following pattern.
12345
1234
123
12
for i in range(n,0,-1):
for j in range(1,(s+1)):
print(end=" ")
for j in range(1,(i+1)):
print(j,end=" ")
s+=2
print()
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
>>>
12345
1234
123
12
>>>
# 9. Write a Program to print Fibonacci Series.
a,b=0,1
print(a)
print(b)
for i in range(2,n):
result=a+b
print(result)
a=b
b=result
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
>>>
0,1,1,2,3,5,8,13,21,34
# 10. Write a Program to find sum of series: s=1+x+x2+.............+xn.
s=0
for a in range(n+1):
s=s+(x**a)
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
>>>
Enter value of x : 2
>>>