0% found this document useful (0 votes)
18 views43 pages

Omkar Jadhav

Uploaded by

shindeom747
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views43 pages

Omkar Jadhav

Uploaded by

shindeom747
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 43

Name = Jadhav Omkar Pundlik

Branch = Artificial Intelligence & Data


Science Roll No. = 17

CODE=

#include <iostream>
#define size 100
using namespace
std;

class Stack {
int top = -1;
char
array[size];

public:
void push(char
val); char pop();
void
display();
char pick();
bool
isempty();
};

// Function to check if the stack is


empty bool Stack::isempty()
{
return top == -1;
}

// Function to push an element to the


stack void Stack::push(char val)
{
if (top >= size - 1)
cout << "Stack is Full" << endl;
els
e
{ top++;
array[top] = val;

}
}

// Function to pop an element from the


stack char Stack::pop()
{
if (top <= -1)
{
e

}
els
c
o
u
t

<
<

"
S
t
a
c
k

E
m
p
t
y
"

<
<

e
n
d
l
;

r
e
t
u
r
n

-
1
;
{
return array[top--];
}
}

// Function to pick the top element of the


stack char Stack::pick()
{
return array[top];
}

// Function to display the elements of the stack (for


debugging) void Stack::display()
{
if (top >= 0)
{
cout << "Stack elements are: ";

for (int i = top; i >= 0; i--)


cout << array[i] << " ";
cout << endl;
}
els
e
{ cout << "Stack is empty" << endl;

}
}

int main()
{
string
str;
Stack s1;
cout << "Enter a string with parentheses to check if balanced:
"; getline(cin, str); // To allow multi-character string input

int flag = 1; // Flag to indicate if the parentheses are


balanced char last_st; // To store the last stacked character

for (int i = 0; str[i] != '\0'; i++)


{
// Push opening brackets onto the stack

if (str[i] == '(' || str[i] == '[' || str[i] ==


'{') s1.push(str[i]);

// Check for closing brackets and match with top of


stack else if (str[i] == ')' || str[i] == ']' ||
str[i] == '}')

{
if (s1.isempty())
{ // No matching opening
bracket flag = 0;
break;
}

last_st = s1.pick();

if ((str[i] == ')' && last_st == '(') ||(str[i] == '}' && last_st


==
'{') ||(str[i] == ']' && last_st == '['))
{
s1.pop(); // If matching, pop the opening bracket
}
els
e
{ flag = 0;
break;

}
}
}

// After parsing the entire string, if stack is not empty, it means


there's an imbalance
if (!s1.isempty())
flag = 0;

// Output the
result if (flag ==
1)
cout << "Parentheses are balanced." << endl;
else
cout << "Parentheses are not balanced." << endl;

return 0;
}

OUTPUT=

Enter a string with parentheses to check if balanced:


{AJH{[G(DFH)D]}GDG} Parentheses are balanced.
Name = Jadhav Omkar Pundlik
Branch = Artificial Intelligence & Data
Science Roll No. = 17

CODE=

#include<iostream
>
#include<string.h
> #define max 50
using namespace std;

class STACK {
private:
char
a[max];
int top;
public:
STACK()
{
top = -1;
}
void
push(char);
void
reverse();
void
convert(char[]);
void palindrome();
};

void STACK::push(char c) {
top++;
a[top] = c;
a[top + 1] = '\0';
}

void STACK::reverse()
{
char str[max];
cout << "\n\nReverse string is: ";
for (int i = top, j = 0; i >= 0; i--, j++)
{
cout << a[i];
str[j] = a[i];
}
cout << endl;
}

void STACK::convert(char
str[]) { int j, k, len =
strlen(str);
for (j = 0, k = 0; j < len; j++)
{
if ((str[j] >= 97 && str[j] <= 122) || (str[j] >= 65 && str[j] <=
90))
{
if (str[j] <= 90)
{
str[k] = (str[j] + 32); // Convert uppercase to lowercase
}
els
e
{ str[k] = str[j];

}
k+
+;
}
}
str[k] = '\0';
cout << endl << "After removing spaces and converting all characters to
lowercase: " << str << "\n";
}

void STACK::palindrome()
{
char
str[max];
int i, j;
for (i = top, j = 0; i >= 0; i--, j++)
{
str[j] = a[i];
}
str[j] = '\0';
if (strcmp(str, a) == 0)
cout << "\n\nString is palindrome...";
els
e cout << "\n\nString is not palindrome...";

int main()
{
STACK stack;
char
str[max];
int i = 0;
cout << "\nEnter string to be reversed and check if it is palindrome or
not: "; cin.getline(str, 50);
cout << "Original String is: " << str;
stack.convert(str);
while (str[i] != '\0')
{
stack.push(str[i]);
i++;
}
stack.palindrome();
stack.reverse();
}
OUTPUT=

Enter string to be reversed and check if it is palindrome or not:


MALAYALAM Original String is: MALAYALAM
After removing spaces and converting all characters to lowercase: malayalam

String is palindrome...
Name = Jadhav Omkar Pundlik
Branch = Artificial Intelligence & Data
Science Roll No. = 17

CODE=

#include<iostream>
using namespace
std; class cinemax
{
public: int booked;
cinemax *next,*prev;
cinemax()
{
next = prev =
NULL; booked=0;
}
}*head[10],*curr,*last;

void build_cinemax()
{
int i,j;
for(i=1;i<=10;i++)
{
for(j=1;j<=7;j++)
{
curr=new cinemax();
if(head[i] == NULL)
{
head[i]=curr;
last=curr;
}
els
e
{ last->next=curr;
last=curr;
last->next=head[i];

}
}
}
}

void display()
{
int i,j;
for(i=1;i<=10;i++)
{
curr = head[i];
cout<<"Row "<<i<<"- - ->";
for(j=1;j<=7;j++)
{
cout<<curr->booked<<"->";
curr= curr->next;
}
cout<<endl;
}
}

void booking()
{
int
row,col,count;
count=1;
cout<<"\n There are 10 rows and 7 cols are present";
cout<<"\n Enter row no...:";
cin>>row;
cout<<"\n Enter col no...:";
cin>>col;
curr=head[row];
while(curr->next != NULL && count <= 7)
{
if(count==col)
{
if(curr->booked!=1)
{
curr->booked=1;
cout<<"\n Seat is booked \n"<<curr-
>booked; display();
break;
}
els
e
{ cout<<"\n Seat is not available";

}
}

else
{
curr=curr->next;
}
count++;
}
}

void cancel()
{
int row,col,count;
count=1;
cout<<"\n Enter row no...:";
cin>>row;
cout<<"\n Enter col no...:";
cin>>col;
curr=head[row];
while(curr->next != NULL && count <= 7)
{
if(count==col)
{
if(curr->booked==1)
{
curr->booked = 0;
cout<<"Seat is cancel"<<curr-
>booked<<endl; cout<<"Current Seat
Status:"<<endl; display();
}
els
e
{ cout<<"\n Seat is not cancel as it is not booked";

} }

els
e curr=curr->next;
{
count+
+; }
}
}

int main()
{
int
i,ch;
char mt;
build_cinemax()
; do
{
cout<<"\n*****Welcome to Cinemax Booking System*****\
n"; cout<<"\n1)Booking";
cout<<"\n2) Booking
Cancel"; cout<<"\
n3)Display"; cout<<"\
nEnter your choice";
cin>>ch;
switch(ch)
{
case 1:
booking();
// display();
break;
case 2: cancel();
//
display();
break;
case 3:
display();
break;
}
}while(ch!=4);

return 0;
}

OUTPUT=

*****Welcome to Cinemax Booking

System***** 1)Booking
2) Booking Cancel
3)Display
Enter your choice1

There are 10 rows and 7 cols are


present Enter row no...:5

Enter col no...:3

Seat is booked
1Row 1------>0->0->0->0->0->0->0->
Row 2------>0->0->0->0->0->0->0->
Row 3------>0->0->0->0->0->0->0->
Row 4------>0->0->0->0->0->0->0->
Row 5------>0->0->1->0->0->0->0->
Row 6------>0->0->0->0->0->0->0->
Row 7------>0->0->0->0->0->0->0->
Row 8------>0->0->0->0->0->0->0->
Row 9------>0->0->0->0->0->0->0->
Row 10------>0->0->0->0->0->0->0->

*****Welcome to Cinemax Booking

System***** 1)Booking
2) Booking Cancel
3)Display
Enter your

choice2 Enter

row no.....................5

Enter col no......3


Seat is cancel0
Current Seat
Status:
Row 1------>0->0->0->0->0->0->0->
Row 2------>0->0->0->0->0->0->0->
Row 3------>0->0->0->0->0->0->0->
Row 4------>0->0->0->0->0->0->0->
Row 5------>0->0->0->0->0->0->0->
Row 6------>0->0->0->0->0->0->0->
Row 7------>0->0->0->0->0->0->0->
Row 8------>0->0->0->0->0->0->0->
Row 9------>0->0->0->0->0->0->0->
Row 10------>0->0->0->0->0->0->0->

Row 9------>0->0->0->0->0->0->0->
Row 10------>0->0->0->0->0->0->0->

Row 10------>0->0->0->0->0->0->0->

*****Welcome to Cinemax Booking System*****

*****Welcome to Cinemax Booking System*****


*****Welcome to Cinemax Booking System*****

1) Booking
2) Booking
Cancel
1)Booking
2) Booking Cancel
3)Display
Enter your choice3
Row 1------>0->0->0->0->0->0->0->
2) Booking Cancel
3)Display
Enter your choice3
Row 1------>0->0->0->0->0->0->0->
Row 2------>0->0->0->0->0->0->0->
Row 3------>0->0->0->0->0->0->0->
Enter your choice3
Row 1------>0->0->0->0->0->0->0->
Row 2------>0->0->0->0->0->0->0->
Row 3------>0->0->0->0->0->0->0->
Row 4------>0->0->0->0->0->0->0->
Row 5------>0->0->0->0->0->0->0->
Row 6------>0->0->0->0->0->0->0->
Row 2------>0->0->0->0->0->0->0->
Row 3------>0->0->0->0->0->0->0->
Row 4------>0->0->0->0->0->0->0->
Row 5------>0->0->0->0->0->0->0->
Row 6------>0->0->0->0->0->0->0->
Row 7------>0->0->0->0->0->0->0->
Row 8------>0->0->0->0->0->0->0->
Row 4------>0->0->0->0->0->0->0->
Row 5------>0->0->0->0->0->0->0->
Row 6------>0->0->0->0->0->0->0->
Row 7------>0->0->0->0->0->0->0->
Row 8------>0->0->0->0->0->0->0->
Row 9------>0->0->0->0->0->0->0->
Row 10------>0->0->0->0->0->0->0->
Row 6------>0->0->0->0->0->0->0->
Row 7------>0->0->0->0->0->0->0->
Row 8------>0->0->0->0->0->0->0->
Row 9------>0->0->0->0->0->0->0->
Row 10------>0->0->0->0->0->0->0->

*****Welcome to Cinemax Booking


System***** Row 7 >0->0->0->0->0->0-
>0->
Row 8------>0->0->0->0->0->0->0->
Row 9------>0->0->0->0->0->0->0->
Row 10------>0->0->0->0->0->0->0->

*****Welcome to Cinemax Booking

System***** Row 9 >0->0->0->0->0->0-

>0->
Row 10------>0->0->0->0->0->0->0->

*****Welcome to Cinemax Booking

System***** 1)Booking

*****Welcome to Cinemax Booking System*****

1) Booking
2) Booking
Cancel
3)Display
1)Booking
2) Booking Cancel
3)Display
2) Booking
Cancel
3)Display
Enter your choice4
Name = Jadhav Omkar Pundlik
Branch = Artificial Intelligence & Data
Science Roll No. = 17

CODE=

#include<iostream>
#include<stdlib.h>
using namespace
std; struct node
{
char
prn[10];
char
name[20];
node *next;
}*precident,*secratory,*new1,*curr;

void creat_list()
{
int count,i;
cout<<"\n Enter total no of members in pinacal list...:";
cin>>count;

for(i=0;i<(count-1);i++)
{
if(precident==NULL && secratory==NULL)
{
precident=new node;
cout<<"\n Enter PRN no of precident...";
cin>>precident->prn;
cout<<"\n Enter name of precident. ";
cin>>precident-
>name; precident-
>next=NULL;
curr=precident;
secratory=new node;
cout<<"\n Enter PRN no of secratory...";
cin>>secratory->prn;
cout<<"\n Enter name of secratory. ";
cin>>secratory-
>name; secratory-
>next=NULL;
}
else
{
new1=new node;
cout<<"\n Enter PRN no of membor. . .";
cin>>new1->prn;
cout<<"\n Enter name of membor..";
cin>>new1-
>name; curr-
>next=new1;
new1->next=secratory;
curr=new1;
}
}
}

OUTPUT=

MENU
1)creat
2)display
3) add
mem
4)revers
e
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice........1

Enter total no of members in pinacal list. 4

Enter PRN no of precident.....

......................................................64738

Enter name of precident...

......................................................Rancho

Enter PRN no of secratory.....

......................................................83765

Enter name of secratory.........shiv

Enter PRN no of membor......

......................................................87355

Enter name of membor....siya

Enter PRN no of membor......

......................................................29834

Enter name of membor....trisha

MENU
1) creat
2)displa
y
3)add mem
4)reverse
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice.......2
64738-Rancho->87355-siya->29834-trisha->83765-
shiv-> MENU
1) creat
2)displa
y
3)add mem
4)reverse
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice........3

Enter PRN no of membor......

......................................................73647

Enter name of membor....hetal

MENU
1) creat
2)displa
y
3)add mem
4)reverse
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice.......4
83765-shiv->73647-hetal->29834-trisha->87355-siya->64738-
Rancho-> MENU
1) creat
2)displa
y
3)add mem
4)reverse
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice.......5

MENU
1) creat
2)displa
y
3)add mem
4)reverse
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice.......6

MENU
1) creat
2)displa
y
3)add mem
4)reverse
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice.......7

Total no. of members in


CLUB:3 MENU
1) creat
2)displa
y
3)add mem
4)reverse
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice.......8
Name = Jadhav Omkar Pundlik
Branch = Artificial Intelligence & Data
Science Roll No. = 17

CODE=

def partition(studMarks, lb, ub):


pivot = studMarks[ub] # Use the last element as the
pivot i = lb - 1
for j in range(lb, ub):
if studMarks[j] <=
pivot: i += 1
studMarks[i], studMarks[j] = studMarks[j],studMarks[i]
studMarks[i + 1], studMarks[ub] = studMarks[ub], studMarks[i +
1] return i + 1

def
quick_sort(studMarks,lb,ub
): if lb<ub:
pivot_index=partition(studMarks,lb,u
b)
quick_sort(studMarks,lb,pivot_index-
1)
quick_sort(studMarks,pivot_index+1,u
b)

def insertion_sort(studMarks):
for i in range(1,
len(studMarks)): key =
studMarks[i]
j = i - 1
while j >= 0 and key <
studMarks[j]: studMarks[j +
1] = studMarks[j] j -= 1
studMarks[j + 1] = key
return studMarks

def print_menu():
print("\nSorting Algorithm
Menu") print("1. Insetion
Sort") print("2. Quick Sort")
print("3.
Exit") def main():
studMarks = []
n = int(input("Enter the number of
students: ")) for _ in range(n):
marks = int(input("Enter the marks:
")) studMarks.append(marks)

while True:
print_menu()
choice = input("Enter your choice (1-3): ")

if choice == '1' or choice ==


'2': if studMarks:
print("Original array:",
studMarks) if choice == '1':
sorted_array = insertion_sort(studMarks.copy())
print("\nSorting Using Insertion Sort")
elif choice == '2':
lb, ub = 0, len(studMarks) - 1
quick_sort(studMarks, lb, ub)
sorted_array =studMarks print("\
nSorting Using Quick Sort")

print("Sorted array:",

sorted_array) else:
print("No valid numbers were entered.")

elif choice == '3':


print("Thank you!")
break

else:
print("Invalid choice. Please enter a number between 1 and 3.")

main()

INPUT=

Enter the number of


students: 5 Enter the marks:
58
Enter the marks:
52 Enter the
marks: 68 Enter
the marks: 62
Enter the marks:
71

OUTPUT=

Sorting Algorithm Menu


1. Insetion Sort
2. Quick Sort
3. Exit
Enter your choice (1-3): 1
Original array: [58, 52, 68, 62, 71]

Sorting Using Insertion Sort


Sorted array: [52, 58, 62, 68,
71]

Sorting Algorithm Menu


1. Insetion Sort
2. Quick Sort
3. Exit
Enter your choice (1-3): 2
Original array: [58, 52, 68, 62, 71]

Sorting Using Quick Sort


Sorted array: [52, 58, 62, 68, 71]

Sorting Algorithm Menu


1. Insetion Sort
2. Quick Sort
3. Exit
Enter your choice (1-3): 3
Thank you!
Name = Jadhav Omkar Pundlik
Branch = Artificial Intelligence & Data
Science Roll No. = 17

CODE=

def selection_sort(arr):
for i in
range(len(arr)):
min_index = i
for j in range(i + 1,
len(arr)): if arr[j] <
arr[min_index]:
min_index = j
arr[i], arr[min_index] = arr[min_index],
arr[i] return arr

def
bubble_sort(arr
): n = len(arr)
for i in range(n):
for j in range(0, n-i-
1): if arr[j] >
arr[j+1]:
arr[j], arr[j+1] = arr[j+1], arr[j]
return arr

def topFive(arr):
print("Top five
students")
last_five=arr[-5:]
top_five=last_five[::-
1] for i in top_five:
print(i)
def
print_menu():
print("\nSorting Algorithm
Menu") print("1. Selection
Sort") print("2. Bubble
Sort") print("3. Exit")
def main():
array=[]
n=int(input("Enter the no. of
students")) for i in range(n):
marks=int(input("Enter your
marks")) array.append(marks)

while True:
print_menu()
choice = input("Enter your choice (1-3): ")

if choice == '1' or choice ==


'2': if array:
print("Original array:",
array) if choice == '1':
sorted_array = selection_sort(array)
print("\n Sorting Using Selection
Sort") elif choice == '2':
sorted_array = bubble_sort(array)
print("\n Sorting Using Bubble Sort")
print("Sorted array:", sorted_array)
print("Top % student:",sorted_array[-1:-
6:-2])
else:
print("No valid numbers were entered.")

elif choice == '3':


print("Thank you!")
break

else:
print("Invalid choice. Please enter a number between 1 and 4.")

main()

INPUT=

Enter the no. of


students 5 Enter your
marks 58
Enter your marks
68 Enter your
marks 57 Enter
your marks 62
Enter your marks
65

OUTPUT=

Sorting Algorithm Menu


1. Selection Sort
2. Bubble Sort
3. Exit
Enter your choice (1-3): 1
Original array: [58, 68, 57, 62, 65]

Sorting Using Selection Sort


Sorted array: [57, 58, 62, 65,
68]

Sorting Algorithm Menu


1. Selection Sort
2. Bubble Sort
3. Exit
Enter your choice (1-3): 2
Original array: [57, 58, 62, 65, 68]

Sorting Using Bubble Sort


Sorted array: [57, 58, 62, 65, 68]
Sorting Algorithm Menu
1. Selection Sort
2. Bubble Sort
3. Exit
Enter your choice (1-3): 3
Thank you!
Name = Shamika Nitin Sonje
Branch = Artificial Intelligence & Data
Science Roll No. = 52

CODE=

def binary_search(roll_stud, target):


first, last = 0, len(roll_stud) - 1
while first <= last:
mid = (first + last) // 2
if roll_stud[mid] == target:
return True
elif target < roll_stud[mid]:
last = mid - 1
else:
first = mid + 1
return False

def fibonacci_search(roll_stud,
target): arr = sorted(roll_stud)
n = len(arr)

fib_2 = 0
fib_1 = 1
fib_3 = fib_1 + fib_2

while fib_3 <


n: fib_2 =
fib_1 fib_1
= fib_3
fib_3 = fib_1 +

fib_2 offset = -1

while fib_3 > 1:


i = min(offset + fib_2, n - 1)

if arr[i] < target:


fib_3 = fib_1
fib_1 = fib_2
fib_2 = fib_3 -
fib_1 offset = i

elif arr[i] >


target: fib_3 =
fib_2
fib_1 = fib_1 -
fib_2 fib_2 = fib_3
- fib_1

else:
return True
if fib_1 and offset + 1 < n and arr[offset + 1] ==
target: return True

return

False def

main():
roll_stud = []
n = int(input("Enter the number of
students: ")) for i in range(n):
roll = int(input("Enter the Roll number: "))
roll_stud.append(roll)

print("Original Roll Numbers:",


roll_stud) roll_stud.sort()
print("Sorted Roll Numbers:", roll_stud)

while True:
target = int(input("Enter the roll number to find out if that
student was present (0 to exit): "))

if target == 0:
print("Exiting.........."
)
break

if target > 0:
if binary_search(roll_stud, target):
print(f"Roll number {target} attended the training program
(Binary
Search)."
) else:
print(f"Roll number {target} did not attend the training
program
(Binary Search).")

if fibonacci_search(roll_stud, target):
print(f"Roll number {target} attended the training
program (Fibonacci Search).")
else:
print(f"Roll number {target} did not attend the training
program (Fibonacci Search).")

else:
print("Roll number not valid!")
main(

INPUT

=
Enter the number of
students: 4 Enter the Roll
number: 25 Enter the Roll
number: 63 Enter the Roll
number: 14
Enter the Roll number: 58

OUTPUT=

Original Roll Numbers: [25, 63, 14, 58]


Sorted Roll Numbers: [14, 25, 58, 63]
Enter the roll number to find out if that student was present (0 to
exit): 58 Roll number 58 attended the training program (Binary Search).
Roll number 58 attended the training program (Fibonacci Search).
Enter the roll number to find out if that student was present (0 to
exit): 30 Roll number 30 did not attend the training program (Binary
Search).
Roll number 30 did not attend the training program (Fibonacci Search).
Enter the roll number to find out if that student was present (0 to
exit): 0 Exiting .....
Name = Jadhav Omkar Pundlik
Branch = Artificial Intelligence & Data
Science Roll No. = 17

CODE=

# Function for average score of the

class def average(listofmarks):


sum=0
count=0
for i in
range(len(listofmarks)):
if listofmarks[i]!=-999:
sum+=listofmarks[i]
count+=1
avg=sum/count
print("Total Marks : ", sum)
print("Average Marks :
{:.2f}".format(avg)) def
maximum(listofmarks):
# Initialize Max with a very low
value Max = float('-inf')

for mark in listofmarks:


if mark != -999: # Ignore the sentinel
value if mark > Max:
Max = mark

return Max
def minimum(listofmarks):
# Initialize Min with a large
number Min = float('inf')
for mark in
listofmarks: if
mark != -999:
if mark < Min:
Min = mark
return Min
def
absentcount(listofmarks)
: count = 0
for mark in
listofmarks: if
mark == -999:
count += 1
return count
# Function for displaying marks with highest
frequency def maxFrequency(listofmarks):
i=0
Max=0
print("Marks |
Frequency") for j in
listofmarks:
if (listofmarks.index(j)==i):
#print(j," | ",listofmarks.count(j))
if
listofmarks.count(j)>M
ax:
Max=listofmarks.count(j
) mark=j
print(j," |
",listofmarks.count(j)) i=i+1
return(mark,Max
) # Main function

marksinFDS=[]
numberofstudents=int(input("Enter total number of students
: ")) for i in range(numberofstudents):
marks=int(input("Enter marks of student "+str(i+1)+" : "))
marksinFDS.append(marks)

flag=1
while flag==1:
print("\n\n MENU \
n") print("1. Total and Average Marks of the Class")
print("2. Highest and Lowest Marks in the Class")
print("3. Number of Students absent for the test")
print("4. Marks with Highest Frequency")
print("5. Exit\n")
ch=int(input("Enter your Choice (from 1 to 5) :"))

if ch==1:
average(marksinFDS)
a = input("Do you want to continue (yes/no)
:") if a == "yes":
flag = 1
else:
flag = 0
print("Thanks for using this program!")

elif ch==2:
print("Highest Score in Class : ",
maximum(marksinFDS)) print("Lowest Score in Class
: ", minimum(marksinFDS)) a = input("Do 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 absent in the test : ",
absentcount(marksinFDS)) a = input("Do you want to continue
(yes/no) :")
if a == "yes":
flag = 1
else:
flag = 0
print("Thanks for using this program!")

elif ch==4:
mark,fr = maxFrequency(marksinFDS)
print("Highest frequency is of marks {0} that is {1}
".format(mark,fr)) a = input("Do 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("Do you want to continue (yes/no)
:") if a=="yes":
flag=1
else:
flag=0
print("Thanks for using this program!")

INPUT=

Enter total number of students


: 8 Enter marks of student 1 :
45 Enter marks of student 2 :
45 Enter marks of student 3 : -
999 Enter marks of student 4 :
67 Enter marks of student 5 :
85 Enter marks of student 6 :
55 Enter marks of student 7 :
60 Enter marks of student 8 :
45

OUTPUT=

MENU

1. Total and Average Marks of the Class


2. Highest and Lowest Marks in the Class
3. Number of Students absent for the test
4. Marks with Highest Frequency
5. Exit

Enter your Choice (from 1 to 5)


: 1 Total Marks : 402
Average Marks : 57.43
Do you want to continue (yes/no) : yes

MENU

1. Total and Average Marks of the Class


2. Highest and Lowest Marks in the Class
3. Number of Students absent for the test
4. Marks with Highest Frequency
5. Exit

Enter your Choice (from 1 to 5) : 2


Highest Score in Class : 85
Lowest Score in Class : 45
Do you want to continue (yes/no) : yes

MENU

1. Total and Average Marks of the Class


2. Highest and Lowest Marks in the Class
3. Number of Students absent for the test
4. Marks with Highest Frequency
5. Exit

Enter your Choice (from 1 to 5) : 3


Number of Students absent in the test
: 1 Do you want to continue
(yes/no) : yes

MENU

1. Total and Average Marks of the Class


2. Highest and Lowest Marks in the Class
3. Number of Students absent for the test
4. Marks with Highest Frequency
5. Exit

Enter your Choice 1 to 5) :


Marks (from 4
| Frequency
45 | 3
45 | 3
-999 | 1
67 | 1
85 | 1
55 | 1
60 | 1
45 | 3
Highest frequency is of marks 45 that
is 3 Do you want to continue
(yes/no) : yes
MENU

1. Total and Average Marks of the Class


2. Highest and Lowest Marks in the Class
3. Number of Students absent for the test
4. Marks with Highest Frequency
5. Exit

Enter your Choice (from 1 to 5) : 5


Thanks for using this program!
Name = Jadhav Omkar Pundlik
Branch = Artificial Intelligence & Data
Science Roll No. = 17

CODE=

def get_student_details():
studentlist=[]
cric = []
badm =
[] foot
= []

n = int(input("Total Number of
students: ")) for i in range(n):
name = input("Enter Name of student: ")
studentlist.append(name)
c = input("Input y if you play cricket: ")
b = input("Input y if you play
badminton: ") f = input("Input y if you
play football: ") if c == 'y':
cric.append(name
) if b == 'y':
badm.append(name
) if f == 'y':
foot.append(name)
return studentlist, cric, badm, foot

def both_crick_and_badm(studentlist, cric, badm):


candb = [i for i in studentlist if i in cric and i in
badm] return candb
def either_crick_or_badm(studentlist, cric, badm):
corb = [i for i in studentlist if (i in cric and i not in badm) or (i in
badm and i not in cric)]
return corb
def football_only(studentlist, cric, badm):
fonly = [i for i in studentlist if i not in cric and i not in
badm] return len(fonly)
def crick_and_foot_not_badm(studentlist, cric, badm, foot):
cfnotb = [i for i in studentlist if i in cric and i in foot and i not
in badm] return len(cfnotb)
studentlist, cric, badm, foot = y
candb = both_crick_and_badm(studentlist, cric, badm)
print("Students playing both cricket and badminton: ", ",
".join(candb)) corb = either_crick_or_badm(studentlist, cric,
badm)
print("Students playing either cricket or badminton but not both:
", ", ".join(corb))
fonly_count = football_only(studentlist, cric, badm)
print("Number of students playing Neither Cricket nor Badminton: ",
fonly_count) cfnotb_count = crick_and_foot_not_badm(studentlist, cric,
badm, foot) print("Number of students playing Cricket and Football but not
Badminton: ",
cfnotb_count)

INPUT=

Total Number of students: 4


Enter Name of student: aditi
Input y if you play cricket:
y Input y if you play
badminton: y Input y if you
play football: n Enter Name
of student: raj Input y if
you play cricket: y Input y
if you play badminton: n
Input y if you play
football: y Enter Name of
student: tanvi Input y if
you play cricket: n Input y
if you play badminton: n
Input y if you play
football: y Enter Name of
student: snehal Input y if
you play cricket: n Input y
if you play badminton: y
Input y if you play
football: n

OUTPUT=

Students playing both cricket and badminton: aditi


Students playing either cricket or badminton but not both: raj,
snehal Number of students playing Neither Cricket nor Badminton: 1
Number of students playing Cricket and Football but not Badminton: 1
Name = Jadhav Omkar Pundlik
Branch = Artificial Intelligence & Data
Science Roll No. = 17

CODE=

def delete(a):
ans = []
for i in
a:
if i not in
ans:
ans.append(i
)
return ans

def count(a):
flag = 0
less = []
for i in
a:
if int(i[1]) > 500:
flag += 1
else:
less.append(i)
return flag, less

def sort(a):
ans = a.copy()
for i in range(0, len(a)):
for j in range(0, len(a) - i - 1):
if ans[j][1] > ans[j + 1]
[1]: temp = ans[j]
ans[j] = ans[j +
1] ans[j + 1] =
temp
return ans

n = int(input("Enter the number of books:


")) books = []
for i in range(n):
name = input("Enter The Name of Book " + str(i + 1) + ": ")
cost = int(input("Enter The Cost of Book " + str(i + 1) + ": "))
books.append([name, cost])

print("Original List : ", books)


books_without_duplicates = delete(books)
print("Delete The Duplicate Entries : ", books_without_duplicates)
sorted_books = sort(books_without_duplicates)
print("Display Books In Ascending Order Based On Cost Of Books : ",
sorted_books) tup = count(books_without_duplicates)
print("Count Number Of Books With Cost More Than 500 : ", tup[0])
print("Copy Books In New List Which Has Cost Less Than 500 : ",
tup[1])
INPUT=
Enter the number of books: 7
Enter The Name of Book 1: DSA
Enter The Cost of Book 1: 550
Enter The Name of Book 2: OS
Enter The Cost of Book 2: 400
Enter The Name of Book 3: CG
Enter The Cost of Book 3: 600
Enter The Name of Book 4: DSA
Enter The Cost of Book 4: 550
Enter The Name of Book 5: DM
Enter The Cost of Book 5: 300
Enter The Name of Book 6: OS
Enter The Cost of Book 6: 400
Enter The Name of Book 7: DSA
Enter The Cost of Book 7: 550

OUTPUT=

Original List : [['DSA', 550], ['OS', 400], ['CG', 600], ['DSA', 550],
['DM',
300], ['OS', 400], ['DSA', 550]]
Delete The Duplicate Entries : [['DSA', 550], ['OS', 400], ['CG', 600],
['DM', 300]]
Display Books In Ascending Order Based On Cost Of Books : [['DM', 300],
['OS', 400], ['DSA', 550], ['CG', 600]]
Count Number Of Books With Cost More Than 500 : 2
Copy Books In New List Which Has Cost Less Than 500 : [['OS', 400], ['DM',
300]]

You might also like