Skip to main content

The Fundamentals of Digital Marketing Certification

The Fundamentals of Digital Marketing Certification
Trying to make use of some spare time during these endless lockdowns. I completed The Fundamentals of Digital Marketing course on Google Digital Garage and got certified. This is not a great victory, nevertheless, I celebrate every small step towards a greater goal. #googlegarage #fundamentalsofdigitalmarketing #digitalmarketing

FDS PR 1

Practical No: -1

Experiment No. 1: In second year computer engineering class, group A students play cricket, group

B students play badminton and group C students play football.

Write a Python program using functions to compute following:

a) List of students who play both cricket and badminton

b) List of students who play either cricket or badminton but not both

c) Number of students who play neither cricket nor badminton

d) number of students who play cricket and football but not badminton.

(Note: while realizing the group, duplicate entries should be avoided, Do not use SET built-in

functions)

Code:

# Function for removing duplicate entries from the group

def removeDuplicate(d):

 lst=[]

 for i in d:

 if i not in lst:

 lst.append(i)

 return lst

#<---------------------------------------------------------------------------------------->

# Function for finding intersection between two sets (A&B)

def intersection(lst1,lst2):

 lst3=[]

 for val in lst1:

 if val in lst2:

 lst3.append(val)

 return lst3 

#<------------------------------------------------------------------------------------------>

# Function for finding union of two sets (A|B)

def union(lst1,lst2):

 lst3=lst1.copy()

 for val in lst2:

 if val not in lst3:

 lst3.append(val)

 return lst3

#<------------------------------------------------------------------------------------------->

# Function for finding difference between two sets (A-B)

def diff(lst1,lst2):

 lst3=[]

 for val in lst1:

 if val not in lst2:

 lst3.append(val)

 return lst3

#<---------------------------------------------------------------------------------------------->

# Function for finding symmetric difference of two sets (A^B)

def sym_diff(lst1,lst2):

 lst3=[]

 D1=diff(lst1,lst2)

 print("Difference between Cricket and Badminton (C-B) is : ", D1)

 D2=diff(lst2,lst1)

 print("Difference between Badminton and Cricket (B-C) is : ", D2)

lst3=union(D1,D2)

 return lst3

#<------------------------------------------------------------------------------------------------>

# Functon for finding List of students who play both cricket and badminton

def CB(lst1,lst2):

 lst3=intersection(lst1,lst2)

 print("\n\nList of students who play both cricket and badminton is : ", lst3)

 return len(lst3)

#<------------------------------------------------------------------------------------------------>

# Function for finding List of students who play either cricket or badminton but not both

def eCeB(lst1,lst2):

 lst3=sym_diff(lst1,lst2)

 print("\nList of students who play either cricket or badminton but not both is : ",lst3)

 return len(lst3)

#<-------------------------------------------------------------------------------------------------->

# Function for finding Number of students who play neither cricket nor badminton

def nCnB(lst1,lst2,lst3):

 lst4=diff(lst1,union(lst2,lst3))

 print("\n\nList of students who play neither cricket nor badminton is : ",lst4)

 return len(lst4)

#<---------------------------------------------------------------------------------------------------> 

# Function for finding Number of students who play cricket and football but not badminton

def CBnF(lst1,lst2,lst3):

 lst4=diff(intersection(lst1,lst2),lst3)

 print("\n\nList of students who play cricket and football but not badminton is : ",lst4)

 return len(lst4)

#<----------------------------------------------------------------------------------------------------->

# Main function

# Creating an empty list for SE COMP

SEComp = []

n = int(input("\nEnter number of students in SE COMP: "))

print("Enter the names of",n,"students (Please press ENTER after entering each students name) :")

for i in range(0, n):

 ele = input()

 SEComp.append(ele) # adding the element

print("Original list of students in SEComp : " + str(SEComp))

#<------------------------------------------------------------------------------------------------------->

# Creating an empty list for Cricket

Cricket = []

n = int(input("\n\nEnter number of students who play cricket : "))

print("Enter the names of",n,"students who play cricket (Please press ENTER after entering each

students name) :")

for i in range(0, n):

 ele = input()

 Cricket.append(ele) # adding the element

print("Original list of students playing cricket is :" +str(Cricket))

Cricket=removeDuplicate(Cricket) 

print("The list of students playing cricket after removing duplicates : " +str(Cricket))

#<------------------------------------------------------------------------------------------------------->

# Creating an empty list for Football

Football = []

n = int(input("\n\nEnter number of students who play football : "))

print("Enter the name of",n,"students who play football (Please press ENTER after entering each

students name) :")

for i in range(0, n):

 ele = input()

 Football.append(ele) # adding the element

print("Original list of students playing football :" +str(Football))

Football=removeDuplicate(Football)

print("The list of students playing football after removing duplicates : " +str(Football))

#<-------------------------------------------------------------------------------------------------------->

# Creating an empty list for Badminton

Badminton = []

n = int(input("\n\nEnter number of students who play badminton : "))

print("Enter the name of",n,"students who play badminton (Please press ENTER after entering each

students name) :")

for i in range(0, n):

 ele = input()

 Badminton.append(ele) # adding the element

print("Original list of students playing badminton :" +str(Badminton))

Badminton=removeDuplicate(Badminton)

print("The list of students playing badminton after removing duplicates : " +str(Badminton))

#<---------------------------------------------------------------------------------------------------------->

flag=1

while flag==1:

 print("\n\n--------------------MENU--------------------\n")

 print("1. List of students who play both cricket and badminton")

 print("2. List of students who play either cricket or badminton but not both")

 print("3. List of students who play neither cricket nor badminton")

 print("4. Number of students who play cricket and football but not badminton")

 print("5. Exit\n")

 ch=int(input("Enter your Choice (from 1 to 5) :"))

 if ch==1:

 print("Number of students who play both cricket and badminton : ", CB(Cricket,Badminton))

 a = input("\n\nDo you want to continue (yes/no) :")

 if a == "yes":

 flag = 1

 else:

 flag = 0

 print("Thanks for using this program!")

 elif ch==2:

 print("Number of students who play either cricket or badminton but not both : ", eCeB(Cricket,

Badminton))

 a = input("\n\nDo you want to continue (yes/no) :")

 if a == "yes":

 flag = 1

 else:

 flag = 0

 print("Thanks for using this program!")

 elif ch==3:

 print("Number of students who play neither cricket nor badminton : ",

nCnB(SEComp,Cricket,Badminton))

a = input("\n\nDo you want to continue (yes/no) :")

 if a == "yes":

 flag = 1

 else:

 flag = 0

 print("Thanks for using this program!")

 elif ch==4:

 print("Number of students who play cricket and football but not badminton : ",

CBnF(Cricket,Football,Badminton))

 a = input("\n\nDo you want to continue (yes/no) :")

 if a == "yes":

 flag = 1

 else:

 flag = 0

 print("Thanks for using this program!")

 elif ch==5:

 flag=0

 print("Thanks for using this program!")

 else:

 print("!!Wrong Choice!! ")

 a=input("\n\nDo you want to continue (yes/no) :")

 if a=="yes":

 flag=1

 else:

 flag=0

 print("Thanks for using this program!")

#<---------------------------------------------END OF PROGRAM--------------------------------------->






Output:

Enter number of students in SE COMP: 8

Enter the names of 8 students (Please press ENTER after entering each students name) :

a

b

c

d

e

f

g

h

Original list of students in SEComp : ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']

Enter number of students who play cricket : 3

Enter the names of 3 students who play cricket (Please press ENTER after entering each students

name) :

a

b

c

Original list of students playing cricket is :['a', 'b', 'c']

The list of students playing cricket after removing duplicates : ['a', 'b', 'c']

Enter number of students who play football : 5

Enter the name of 5 students who play football (Please press ENTER after entering each students

name) :

a

e

c

g

h

Original list of students playing football :['a', 'e', 'c', 'g', 'h'] 

The list of students playing football after removing duplicates : ['a', 'e', 'c', 'g', 'h']

Enter number of students who play badminton : 8

Enter the name of 8 students who play badminton (Please press ENTER after entering each students

name) :

a

b

c

d

e

g

f

h

Original list of students playing badminton :['a', 'b', 'c', 'd', 'e', 'g', 'f', 'h']

The list of students playing badminton after removing duplicates : ['a', 'b', 'c', 'd', 'e', 'g', 'f', 'h']

--------------------MENU--------------------

1. List of students who play both cricket and badminton

2. List of students who play either cricket or badminton but not both

3. List of students who play neither cricket nor badminton

4. Number of students who play cricket and football but not badminton

5. Exit

Enter your Choice (from 1 to 5) :1

List of students who play both cricket and badminton is : ['a', 'b', 'c']

Number of students who play both cricket and badminton : 3

Do you want to continue (yes/no) :yes

--------------------MENU--------------------

1. List of students who play both cricket and badminton

2. List of students who play either cricket or badminton but not both

3. List of students who play neither cricket nor badminton 

4. Number of students who play cricket and football but not badminton

5. Exit

Enter your Choice (from 1 to 5) :2

Difference between Cricket and Badminton (C-B) is : []

Difference between Badminton and Cricket (B-C) is : ['d', 'e', 'g', 'f', 'h']

List of students who play either cricket or badminton but not both is : ['d', 'e', 'g', 'f', 'h']

Number of students who play either cricket or badminton but not both : 5

Do you want to continue (yes/no) :yes

--------------------MENU--------------------

1. List of students who play both cricket and badminton

2. List of students who play either cricket or badminton but not both

3. List of students who play neither cricket nor badminton

4. Number of students who play cricket and football but not badminton

5. Exit

Enter your Choice (from 1 to 5) :3

List of students who play neither cricket nor badminton is : []

Number of students who play neither cricket nor badminton : 0

Do you want to continue (yes/no) :yes

--------------------MENU--------------------

1. List of students who play both cricket and badminton

2. List of students who play either cricket or badminton but not both

3. List of students who play neither cricket nor badminton

4. Number of students who play cricket and football but not badminton

5. Exit 

Enter your Choice (from 1 to 5) :4

List of students who play cricket and football but not badminton is : []

Number of students who play cricket and football but not badminton : 0

Do you want to continue (yes/no) :yes

--------------------MENU--------------------

1. List of students who play both cricket and badminton

2. List of students who play either cricket or badminton but not both

3. List of students who play neither cricket nor badminton

4. Number of students who play cricket and football but not badminton

5. Exit

Enter your Choice (from 1 to 5) :5

Thanks for using this program! 

 

GALLERY

GALLERY
photos

ABOUT

HTML CSS, VB.net Developer and Java, C programming. With Loves Problem Solving and to Unreval the Mysteries behind the Magic of Computer Programming

Followers

MY PROJECTS

Popular posts from this blog

FDS 12

 Practical No: -12 Experiment No. 12: A double-ended queue(deque) is a linear list in which additions and deletions may be made at either end. Obtain a data representation mapping a deque into a one-dimensional array. Write C++ program to simulate deque with functions to add and delete elements from either end of the deque. Code: using namespace std; #include<iostream> #include<stdio.h> #include<process.h> #define MAX 30 typedef struct dequeue {  int data[MAX];  int rear,front; }dequeue; void initialize(dequeue *p); int isEmpty(dequeue *p); int isFull(dequeue *p); void enqueueRear(dequeue *p,int x); void enqueueFront(dequeue *p,int x); int dequeueFront(dequeue *p); int dequeueRear(dequeue *p); void display(dequeue *p); main() {  int i,x,choice,n;  dequeue q;  initialize(&q);  do  {  cout<<"\n 1.Create \n 2.Insert(rear) \n 3.Insert(front) \n 4.Delete(rear) \n 5.Delete(front)";  cout<<"\n 6.Display \n 7.Ex...

dsa

 https://drive.google.com/drive/folders/1xaWUPlioGjpK0WAmAD-mvlxAuA8eTK1c https://github.com/khan0003-py/SPPU-Computer-4th-Sem-Lab-Codes/tree/master/DSAL

FDS 11

 Practical No: -11 Experiment No. 11: Queues are frequently used in computer programming, and a typical example is the creation of a job queue by an operating system. If the operating system does not use priorities, then the jobs are processed in the order they enter the system. Write C++ program for simulating job queue. Write functions add job and delete job from queue. Code: using namespace std; #include<iostream> #include<stdio.h> #include<conio.h> #include<stdlib.h> #define SIZE 5 void enqueue(int x); void dequeue(); void display(); int FRONT=-1; int REAR=-1; int QUEUE[SIZE]; main() {  int x,ch;  while(1)  {  cout<<"\n 1:Add Job";  cout<<"\n 2:Delete Job";  cout<<"\n 3:Display";  cout<<"\n 4:Exit";  cout<<"\n Enter Your Choice:";  cin>>ch;  switch(ch)  {  case 1:  cout<<"Enter Job:";  cin>>x;  enqueue(x);  break;  case 2: ...

Contact us

Name

Email *

Message *