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 5

 Practical No: -5

Experiment No. 6: Write a python program to store first year percentage of students in array. Write

function for sorting array of floating-point numbers in ascending order using

a) Selection Sort

b) Bubble sort and display top five score

Code:

# Function for Selection Sort of elements

def Selection_Sort(marks):

 for i in range(len(marks)):

 # Find the minimum element in remaining unsorted array

 min_idx = i

 for j in range(i + 1, len(marks)):

 if marks[min_idx] > marks[j]:

 min_idx = j

 # Swap the minimum element with the first element

 marks[i], marks[min_idx] = marks[min_idx], marks[i]

 print("Marks of students after performing Selection Sort on the list : ")

 for i in range(len(marks)):

 print(marks[i])

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

# Function for Bubble Sort of elements

def Bubble_Sort(marks):

 n = len(marks)

 # Traverse through all array elements

 for i in range(n - 1):

 # Last i elements are already in place

 for j in range(0, n - i - 1):

 # Traverse the array from 0 to n-i-1

 # Swap if the element found is greater than the next element

 if marks[j] > marks[j + 1]:

 marks[j], marks[j + 1] = marks[j + 1], marks[j]

 print("Marks of students after performing Bubble Sort on the list :")

 for i in range(len(marks)):

 print(marks[i])

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

# Function for displaying top five marks

def top_five_marks(marks):

 print("Top",len(marks),"Marks are : ")

 print(*marks[::-1], sep="\n")

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

# Main

marks=[]

n = int(input("Enter number of students whose marks are to be displayed : "))

print("Enter marks for",n,"students (Press ENTER after every students marks): ")

for i in range(0, n):

 ele = int(input())

 marks.append(ele) # adding the element

print("The marks of",n,"students are : ")

print(marks)

flag=1;

while flag==1:

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

 print("1. Selection Sort of the marks")

 print("2. Bubble Sort of the marks")

 print("3. Exit")

 ch=int(input("\n\nEnter your choice (from 1 to 3) : "))

 if ch==1:

 Selection_Sort(marks)

 a=input("\nDo you want to display top marks from the list (yes/no) : ")

 if a=='yes':

 top_five_marks(marks)

 else:

 print("\nThanks for using this program!")

 flag=0

 elif ch==2:

 Bubble_Sort(marks)

 a = input("\nDo you want to display top five marks from the list (yes/no) : ")

 if a == 'yes':

 top_five_marks(marks)

 else:

 print("\nThanks for using this program!")

 flag = 0

 elif ch==3:

 print("\nThanks for using this program!!")

 flag=0

 else:

 print("\nEnter a valid choice!!")

 print("\nThanks for using this program!!")

 flag=0

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





Output:

Enter number of students whose marks are to be displayed : 5

Enter marks for 5 students (Press ENTER after every students marks):

70

80

60

50

40

The marks of 5 students are :

[70, 80, 60, 50, 40]

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

1. Selection Sort of the marks

2. Bubble Sort of the marks

3. Exit

Enter your choice (from 1 to 3) : 1

Marks of students after performing Selection Sort on the list :

40

50

60

70

80

Do you want to display top marks from the list (yes/no) : yes

Top 5 Marks are :

80

70

60

50

40

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

1. Selection Sort of the marks

2. Bubble Sort of the marks

3. Exit

Enter your choice (from 1 to 3) : 2

Marks of students after performing Bubble Sort on the list :

40

50

60

70

80

Do you want to display top five marks from the list (yes/no) : yes

Top 5 Marks are :

80

70

60

50

40

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

1. Selection Sort of the marks

2. Bubble Sort of the marks

3. Exit

Enter your choice (from 1 to 3) : 3

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 *