PYTHON Programming
PYTHON Programming
PYTHON Programming
Practical File
CERTIFICATE
This is to certify that python Programming Practical File being submitted is a bonafide work
done by DAKSH Student of BCA 3rd Sem 2nd shift in partial fulfilment of the award of the
BCA degree.
He has worked under my guidance and supervision and has fulfilled the requirements of the
file that has been reached the requisite standards.
ACKNOWLEDGEMENT
I, DAKSH , the student of BCA 3rd Sem, am extremely grateful to JIMS college for the
confidence bestowed in me and entrusting my Practical file of python Programming.
I take this opportunity to thank all the lab assistants, coordinators who have directly or
indirectly without which this file would not have been possible. Lastly but not the least I place
a deep sense of gratitude to my family members and my friends who have been constant
source of inspiration during the preparation of this Practical file
Student Name:
DAKSH
Date: 5TH January, 2022
CONTENTS
S Programs Date Signature
no.
1 WAP to enter 2 integers, 2 floating numbers and 22-Sep-
perform various arithmetic operations on them. 2022
WAP to check whether a number is an Armstrong
number or not.
2 WAP to check whether a number is an Armstrong 29-Sep-
number or not. 2022
3 WAP to print sum of all prime numbers between 5-Oct-
2 ranges. 2022
4 WAP to swap 2 strings 16-Oct-
2022
5 Write a menu driven program to accept 2 strings 22-Oct-
and perform the various functions using user 2022
defined functions.
6 WAP to find smallest and largest number in a 30-Oct-
string 202
7 Create a dictionary whose keys are month names 3-Nov-
and whose values are the days in corresponding 2022
month. · Ask user to enter a month name and
use dictionary to tell them how many days are
there in the month. · Print out all keys in
alphabetically order · Print out key value pair
sorted by number of days in each month.
8 Make a list of first 10 letters of alphabet, then 20-Nov-
use the slicing to do the following operations: · 2022
Print the first 3 letters of list. · Print any 3 letters
from middle of list · Print the letter from any
particular index to the end of list.
9 WAP that scans an email index and forms a tuple 29-Nov-
of username and domain. 202
10 WAP that uses a user defined function that 9-Dec-
accepts name and gender and prefixes Mr./Mrs. 2022
On the basis of gender.
OUTPUT:
OUTPUT:
Q3-Write a program to print the sum of all the primes between two ranges.
CODE:
sum=0
for i in range(2,10):
for j in range(2,i//2+1):
if i%j==0:
sum=sum+j
print("sum of prime numbers: ",sum)
OUTPUT:
OUTPUT:
Q5-write a menu driven program to accept two strings from the user and
perform the various functions using user defined functions.
CODE:
def performing_actions(str1,str2):
choice = 1
while choice != 4:
print('1 for concatenating strings')
print('2 for swaping strings')
print('3 for checking length of both strings')
print('4 for exit')
choice = int(input("Enter the option you want to choose: "))
if choice ==1:
print('Concatenating both strings: ',str1+' '+str2)
elif choice ==2:
a = str1; b = str2
a,b = b,a
print('Swaping both strings: ',a,b)
elif choice == 3:
print('Length of string1: ',len(str1),'and string2: ',len(str2))
elif choice == 4:
break
str1 = input("Enter first string: ")
str2 = input("Enter second string")
performing_actions(str1,str2)
OUTPUT:
OUTPUT:
Q7. Create a dictionary whose keys are month name and whose values are
number of days in the corresponding month:
(a) Ask the user to enter the month name and use the dictionary to tell how
many days are in month.
(d) Print out the (key - value) pair sorted by the number of the days in each
month.
CODE:
OUTPUT:
d) month = { "jan" : 31 , "feb" : 28 , "march" : 31 , "april" : 30 , "may" : 31 , "june" : 30 , "july" : 31 , "aug" : 31 , "sept" : 30
, "oct" : 31 , "nov" : 30 , "dec" : 31}
print("feb")
for i in month :
if month [ i ] == 30 :
print(i)
for i in month :
if month [ i ] == 31 :
OUTPUT:
:
Q8-Write a Python program for the following:Make a list of first ten letters
of the alphabet, then using the slice operation do thefollowing
operations.A.Print the first three letters from the list.B.Print any three
letters from the middle.C.Print the letters from any particular index to the
end of the list.
CODE:
l1=['a','b','c','d','e','f',
'g','h','i','j']
print(l1[0:3])
OUTPUT:
b) l1=['a','b','c','d','e','f',
'g','h','i','j']
print(l1[2:5])
OUTPUT:
c) l1=['a','b','c','d','e','f',
'g','h','i','j']
print(l1[4:11])
OUTPUT:
Q9- write a program to sacn an email address and forms a tuple of user name
and domain.
CODE:
test_str = '[email protected]'
print("The original string is : " + str(test_str))
res = test_str[test_str.index('@') + 1 : ]
print("The extracted domain name : " + str(res))
OUTPUT:
OUTPUT: