Professional Documents
Culture Documents
Practical File
Page
Ser Objective Signature
No
Write a Program in Python to check whether a given
(i) 1
number is Armstrong Number?
Write a Program in Python to find MAX number among
(ii) 2
three numbers.
Write a Program in Python to print Fibonacci Series for a
(iii) 3
number.
Write a Program in Python to print table for a given number
(iv) 4
by using for loop.
Write a Program in Python to Input a number and check if
(v) 5
the number is a prime or composite number.
Write a Program in Python to print following pattern.
12345
1234
(vi) 6
123
12
1
Write a Program in Python to print following * pattern.
Enter the Number of Rows : 04
*******
(vii) 7
*****
***
*
Write a Program in Python to find out middle number among
(viii) 8
three numbers.
Write a Program in Python to print following * pattern.
*
**
(ix) 9
***
****
*****
Write a Program in Python to Input a string and determine
(x) 10
whether it is a palindrome or not?
Write a Program in Python to find sum of list elements.
(xi) 11
Write a Program in Python to find Min or Max number in the
(xii) 12
List.
(xiii) Write a Program in Python to Reverse the List itself. 13
Write a Program in Python to Shift all the elements of the
(xiv) 14
List one step Left.
Write a Program in Python to count the number of times a
(xv) 15
character appears in a given string using a dictionary.
Write a Program in Python to Delete a given number from
(xvi) the List. 17
Page
Ser Objective Signature
No
Write a Program in Python to accept a List & a value ‘n’ 18
(xvii)
from user & Left shift all elements of List ‘n’ times.
Write a Program in Python to accept a List & a value ‘n’ 19
(xviii)
from user & Right shift all elements of List ‘n’ times.
Write a Program in Python to Store Students’ detail in 21
(xix) Dictionary and Display Information on the basis of School
Number.
Write a Program in Python to Insert an element at a given 23
(xx) position in the List.
PROGRAM – 1
Objective:
Write a Program in Python to check whether a given number is
Armstrong Number?
Program Code:
Output:
[5977] Page 1
PROGRAM – 2
Objective:
Write a Program in Python to find MAX number among three numbers.
Program Code:
Output:
[5977] Page 2
PROGRAM – 3
Objective:
Write a Program in Python to print Fibonacci Series for a number.
Program Code:
i=int(input("Enter how many numbers of Fibonacci
series to be printed : "))
a=0
b=1
c=0
for z in range(i):
print(c)
a=b
b=c
c=a+b
Output:
[5977] Page 3
PROGRAM – 4
Objective:
Write a Program in Python to print table for a given number by using for
loop.
Program Code:
num=int(input("Enter the number to print table of :
"))
for i in range (1,11):
print(num,'x',i,'=',num*i)
Output:
[5977] Page 4
PROGRAM – 5
Objective:
Write a Program in Python to Input a number and check if the number is
a prime or composite number.
Program Code:
n=int(input("enter any number : "))
if (n==0 or n==1):
elif n>1:
if(n%i==0):
break
else:
else:
Output:
[5977] Page 5
PROGRAM – 6
Objective:
12345
1234
123
12
1
Program Code:
Output:
[5977] Page 6
PROGRAM – 7
Objective:
Write a Program in Python to print following * pattern.
*******
*****
***
Program Code:
a=7
for i in range(4):
print("*"*a)
print(" "*i,end=" ")
a=a-2
Output:
[5977] Page 7
PROGRAM – 8
Objective:
Write a Program in Python to find out middle number among three
numbers.
Program Code:
Output:
[5977] Page 8
PROGRAM – 9
Objective:
Write a Program in Python to print following * pattern.
**
***
****
*****
Program Code:
n=int(input("Enter the number of lines : "))
for i in range(1,n+1):
print("*"*i)
Output:
[5977] Page 9
PROGRAM – 10
Objective:
Write a Program in Python to Input a string and determine whether it is a
palindrome or not?
Program Code:
string=input("Enter the string to check : ")
if string==string[::
string==string[::-1]:
print("The string is Palindrome.......")
else:
print("The string is not Palindrome......")
Output:
[5977] Page 10
PROGRAM – 11
Objective:
Write a Program in Python to find sum of list elements.
Program Code:
L=[]
size=int(input("Enter the size of list : "))
for i in range(size):
x=int(input("Enter the elements of the list : "))
L.append(x)
print("The original list is : ",L)
sum=0
for i in range(size):
sum=sum+L[i]
print("The sum of all numbers is : ",sum)
Output:
[5977] Page 11
PROGRAM – 12
Objective:
Write a Program in Python to find Min or Max number in the List.
Program Code:
L=[]
size=int(input("Enter the size of list : "))
for i in range(size):
x=int(input("Enter the elements of the list : "))
L.append(x)
print("The original list is : ",L)
max=L[0]
for i in range(size):
if(max<L[i]):
max=L[i]
print("The max number among the list is : ",max)
min=L[0]
for i in range(size):
if(min>L[i]):
min=L[i]
print("The min number among the list is : ",min)
Output:
[5977] Page 12
PROGRAM – 13
Objective:
Write a Program in Python to Reverse the List itself.
Program Code:
L=[]
for i in range(size):
L.append(x)
a=0
b=size-1
while(a<b):
temp=L[a]
L[a]=L[b]
L[b]=temp
a=a+1
b=b-1
Output:
[5977] Page 13
PROGRAM – 14
Objective:
Write a Program in Python to Shift all the elements of the List one step
Left.
Program Code:
L=[]
for i in range(size):
L.append(x)
key=L[0]
for i in range(1,size):
L[i-1]=L[i]
L[size-1]=key
Output:
[5977] Page 14
PROGRAM – 15
Objective:
Write a Program in Python to count the number of times a character
appears in a given string using a dictionary.
Program Code:
string=input("Enter the string to check : ")
dict={}
for i in string:
if i in dict:
dict[i]+=1
else:
dict[i]=1
Output:
[5977] Page 15
PROGRAM – 16
Objective:
Program Code:
L=[]
size=int(input("Enter the size of list : "))
for i in range(size):
x=int(input("Enter the elements of the list : "))
L.append(x)
print("The original list is : ",L)
key=int(input("Enter the value to delete : "))
flag=0
for i in range(size):
if L[i]==key:
flag=1
pos=i
break
if flag==0:
print("Element not found in list.")
else:
for i in range(pos,size-1):
L[i]=L[i+1]
L.pop()
print("The list after deletation is : ",L)
[5977] Page 16
Output:
[5977] Page 17
PROGRAM – 17
Objective:
Write a Program in Python to accept a List & a value ‘n’ from user & Left
shift all elements of List ‘n’ times.
Program Code:
L=[]
for i in range(size):
L.append(x)
for x in range(n):
temp=L[0]
for i in range(1,size):
L[i-1]=L[i]
L[size-1]=temp
[5977] Page 18
Output:
[5977] Page 19
PROGRAM – 18
Objective:
Write a Program in Python to accept a List & a value ‘n’ from user &
Right shift all elements of List ‘n’ times.
Program Code:
L=[]
for i in range(size):
L.append(x)
for x in range(n):
temp=L[size-1]
for i in range(size-1,-1,-1):
L[i]=L[i-1]
L[0]=temp
Output:
[5977] Page 20
PROGRAM – 19
Objective:
Program Code:
stud_DB={}
while True:
if data=="Q":
break
ID,Name=data.split(',')
stud_DB.update({ID:Name})
#Show Dictionary
print(x,y)
if key in stud_DB:
print("Key=",key,"Value=",stud_DB[key])
else:
[5977] Page 21
Output:
[5977] Page 22
PROGRAM – 20
Objective:
Program Code:
L=[]
for i in range(size):
L.append(x)
L.append(None)
for i in range(size-1,pos-2,-1):
L[i+1]=L[i]
L[pos-1]=key
[5977] Page 23
Output:
[5977] Page 24
PROJECT
PROGRAM CODE:
def rowprint(x):
y=1
y+=1
print()
def rowprint1(x):
y=1
print(y,"\t",i[0:5] ,"\t\t",j[0],
"\t\t₹",j[1]/1000,"k","\t\t₹",(j[1]*j[0])/1000,"k")
y+=1
print()
def change(x):
(item,cost)=x.split(',')
store.update({item:[int(cost)]})
store={"CPU":[50000],"Mouse":[1800],"Keyboard":[1000]
,"Moniter":[20000],"Tablet":[15000],"Pendrive":[1850]
,"Router":[11500],\
[5977] Page 25
"Webcam":[1200],"Mic":[1800],"Headphone":[2300],"Spea
ker":[1300]}
while True:
cart={}
print()
if a=="O":
rowprint(store)
while True:
print()
if x=="D":
break
change(x)
rowprint(store)
elif a=="C":
rowprint(store)
while True:
if x=="D":
[5977] Page 26
break
elif x in store:
print()
cart.update({x:[q,store[x][0]]})
if i[0]==0:
cart.pop(j)
break
rowprint1(cart)
else:
print()
print()
sum=0
rowprint1(cart)
for i in cart.values():
sum+=i[1]*i[0]
print("Total Amount :
\t\t\t\t\t\t\t₹",sum/1000,'k')
elif a=="E":
break
[5977] Page 27
else:
[5977] Page 28
Output:
[5977] Page 29
[5977] Page 30