Input: "Enter String: "
Input: "Enter String: "
PROBLEM STATEMENT -: WAP to count the frequency of words in a string the output should be displayed
in the dictionary format where each unique word of the string will be the key in the dictionary and its
frequency will be the value of dictionary.
Program: -
1. string=input("Enter string: ").split() #input string and convert to list
2. d={} #initialize an empty dictionary
3. l=[] #initialize an empty list
4. for i in string: #iterating through string
if i not in l:
l=[i]
d[i]=string.count(i) #assigning the frequency to the
else: pass word
PYTHON LAB
NAME- AYUSH KUMAR ROLL NO.-25 BCA(SEM-III) SEC A STUDEN ID-
20151034
PYTHON LAB
NAME- AYUSH KUMAR ROLL NO.-25 BCA(SEM-III) SEC A STUDEN ID-
20151034
Program: -
PYTHON LAB
NAME- AYUSH KUMAR ROLL NO.-25 BCA(SEM-III) SEC A STUDEN ID-
20151034
PYTHON LAB
NAME- AYUSH KUMAR ROLL NO.-25 BCA(SEM-III) SEC A STUDEN ID-
20151034
PROBLEM STATEMENT -: Write a python program to print all the prime numbers below 100.
Program: -
1. l = [] #list for storing prime numbers
2. for i in range(2,100):
t=1 #flag
for x in l: #traversing elements of list containing prime numbers
if i%x==0:
t=0
break
if t==1: #if flag is 1
l.append(i) #add to list
3. for i in l:
print(i,end=',')
PYTHON LAB
NAME- AYUSH KUMAR ROLL NO.-25 BCA(SEM-III) SEC A STUDEN ID-
20151034
PYTHON LAB
NAME- AYUSH KUMAR ROLL NO.-25 BCA(SEM-III) SEC A STUDEN ID-
20151034
PROBLEM STATEMENT -: Write a python script to create a list of n variables. Take a value from user which
will be replaced by another value given by the user. The list can be heterogeneous.
Program: -
PYTHON LAB
NAME- AYUSH KUMAR ROLL NO.-25 BCA(SEM-III) SEC A STUDEN ID- 20151034
Output: -
PYTHON LAB
NAME- AYUSH KUMAR ROLL NO.-25 BCA(SEM-III) SEC A STUDEN ID-
20151034
PROBLEM STATEMENT -: Write a recursive function to find the factorial of a given number.
Program: -
PYTHON LAB
NAME- AYUSH KUMAR ROLL NO.-25 BCA(SEM-III) SEC A STUDEN ID- 20151034
Output:
PYTHON LAB
NAME- AYUSH KUMAR ROLL NO.-25 BCA(SEM-III) SEC A STUDEN ID-
20151034
Problem Statement: - Write a function dups to find whether there are duplicates in the list.
Program: -
1. def dups(list_1):
for i in list_1:
if list_1.count(i)>1:
return True
else: return False
2. list_a = [1,2,3,4,5,1,2,4,5,123,34]
PYTHON LAB
NAME- AYUSH KUMAR ROLL NO.-25 BCA(SEM-III) SEC A STUDEN ID-
20151034
Output:
PYTHON LAB