Atharv Bhambare
Atharv Bhambare
Atharv Bhambare
for i in sentence:
if i in all_freq:
all_freq[i] += 1
else:
all_freq[i] = 1
# printing result
print("Count of all characters in sentence is :\n "
+ str(all_freq))
text="malayalam"
print("Given text is "+text)
rev=reversed(text)
if list(text)==list(rev):
print("its a palindrome")
else:
print("its not a palindrome")
def main():
# call freq function
freq(sentence)
Output:
root@root123-HP-ProDesk-600-G3-SFF:/home/root123# python3
student.py
root@root123-HP-ProDesk-600-G3-SFF:/home/root123#
Name :- BHAMBARE ATHARV ACHYUT
Class :- S.E. Computer
Subject :- DSL
Roll No :- 06
k = 0
while k < m: # Fix: Change to m instead of n
if row_min < a[k][ci]:
break
k += 1
if k == m:
print("The saddle point is:", row_min)
f = 1
break # Fix: Add break to exit the loop if
saddle point is found
if f == 0:
print("Saddle point does not exist")
Output:-
root@root123-HP-ProDesk-600-G3-SFF:/home/root123# python3
student.py
root@root123-HP-ProDesk-600-G3-SFF:/home/root123#
Name :- BHAMBARE ATHARV ACHYUT
Class :- S.E. Computer
Subject :- DSL
Roll No :- 06
'''
def Selection_Sort(marks):
for i in range(len(marks)):
#<------------------------------------------------------------
--------------------------->
def Bubble_Sort(marks):
n = len(marks)
#<------------------------------------------------------------
--------------------------->
#<------------------------------------------------------------
---------------------------->
# Main
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)
elif ch==2:
Bubble_Sort(marks)
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:-
root@root123-HP-ProDesk-600-G3-SFF:/home/root123# python3
student.py
---------------MENU---------------
1. Selection Sort of the marks
2. Bubble Sort of the marks
3. Exit
Do you want to display top marks from the list (yes/no) : yes
Top 5 Marks are :
90
84
77
63
25
---------------MENU---------------
1. Selection Sort of the marks
2. Bubble Sort of the marks
3. Exit
Do you want to display top five marks from the list (yes/no) : no
root@root123-HP-ProDesk-600-G3-SFF:/home/root123#
Name :- BHAMBARE ATHARV ACHYUT
Class :- S.E. Computer
Subject :- DSL
Roll No :- 06
#include<iostream>
using namespace std;
int main()
{
float marks[20];
int i, n, ch;
return 0;
}
Output:-
root@root123-HP-ProDesk-600-G3-SFF:/home/root123# python3
student.py
#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 quick sort
def input_percentage():
perc = []
while True:
perc[lower_bound], perc[upper_bound] =
perc[upper_bound], perc[lower_bound]
else:
break
# Main
unsorted_percentage = []
sorted_percentage = []
flag = 1
while flag == 1:
print("\nMENU")
print("1. Accept the Percentage of Students")
print("2. Display the Percentages of Students")
print("3. Perform Quick Sort on the Data")
print("4. Exit")
if ch == 1:
unsorted_percentage = input_percentage()
elif ch == 2:
print_percentage(unsorted_percentage)
elif ch == 3:
sorted_percentage = Quick_Sort(unsorted_percentage,
0, len(unsorted_percentage) - 1)
print_percentage(sorted_percentage)
Output:-
root@root123-HP-ProDesk-600-G3-SFF:/home/root123# python3
student.py
MENU
1. Accept the Percentage of Students
2. Display the Percentages of Students
3. Perform Quick Sort on the Data
4. Exit
Enter your choice (from 1 to 4) : 1
Enter the number of Students : 3
Enter the percentage of Student 1 : 89
Enter the percentage of Student 2 : 77
Enter the percentage of Student 3 : 56
MENU
1. Accept the Percentage of Students
2. Display the Percentages of Students
3. Perform Quick Sort on the Data
4. Exit
Enter your choice (from 1 to 4) : 2
89.0
77.0
56.0
MENU
1. Accept the Percentage of Students
2. Display the Percentages of Students
3. Perform Quick Sort on the Data
4. Exit
Enter your choice (from 1 to 4) : 3
Percentages of Students after performing Quick Sort :
56.0,77.0,89.0
root@root123-HP-ProDesk-600-G3-SFF:/home/root123#
Name :- BHAMBARE ATHARV ACHYUT
Class :- S.E. Computer
Subject :- DSL
Roll No :- 06
#include <iostream>
#include <stdlib.h>
class node
{
public:
node* next;
node* prev;
int seat;
string id;
int status;
};
class cinemax
{
public:
node* head, *tail, *temp;
cinemax()
{
head = NULL;
}
void create_list();
void display();
void book();
void cancel();
void avail();
};
void cinemax::create_list()
{
int i = 1;
temp = new node;
temp->seat = 1;
temp->status = 0;
temp->id = "null";
tail = head = temp;
void cinemax::display()
{
int r = 1;
node* temp = head;
int count = 0;
if (temp->status == 0)
cout << "| | ";
else
cout << "|_B_| ";
count++;
if (count % 7 == 0)
{
cout << endl;
r++;
}
temp = temp->next;
}
void cinemax::book()
{
int x;
string y;
label:
while (temp->seat != x)
{
temp = temp->next;
}
if (temp->status == 1)
cout << "Seat already booked!\n";
else
{
temp->status = 1;
temp->id = y;
cout << "Seat " << x << " booked!\n";
}
}
void cinemax::cancel()
{
int x;
string y;
label1:
while (temp->seat != x)
{
temp = temp->next;
}
if (temp->status == 0)
{
cout << "Seat not booked yet!!\n";
}
else
{
if (temp->id == y)
{
temp->status = 0;
cout << "Seat Cancelled!\n";
}
else
void cinemax::avail()
{
int r = 1;
node* temp = head;
int count = 0;
if (temp->status == 0)
cout << "| | ";
else if (temp->status == 1)
cout << " ";
count++;
if (count % 7 == 0)
{
cout << endl;
}
temp = temp->next;
}
if (temp->status == 0)
{
cout << "S" << temp->seat << ":";
if (temp->status == 0)
cout << "| | ";
}
}
int main()
{
cinemax obj;
obj.create_list();
int ch;
char c = 'y';
while (c == 'y')
{
obj.display();
cout <<
"\n*********************************************\n";
cout << " CINEMAX MOVIE THEATRE\n";
cout <<
"*********************************************\n";
switch (ch)
{
case 1:
obj.display();
break;
case 2:
obj.book();
break;
case 3:
obj.avail();
break;
case 4:
obj.cancel();
break;
default:
cout << "Wrong choice input\n";
}
cout << "\nDo you want to perform any other
operation : (y/n)\n";
cin >> c;
}
return 0;
}
Output:-
root@root123-HP-ProDesk-600-G3-SFF:/home/root123# python3
student.py
Enter Choice
1. Current SeatStatus
2. Book Seat
3. Available Seat
4. Cancel Seat
Screen this way
Enter Choice
1. Current SeatStatus
2. Book Seat
3. Available Seat
4. Cancel Seat
2
#include <stdio.h>
#include <stdlib.h>
node *createnode()
{
int n, i;
node *p, *head, *t;
head = NULL;
p = (node *)malloc(sizeof(node));
printf("Enter the student's data:
"); scanf("%d", &(p->data)); p->next
= NULL;
if (head == NULL)
head = p;
else
{
t = head;
while (t->next != NULL)
t = t->next;
t->next = p;
}
}
return head;
}
if (found != 1)
{
printf("\t %d", q->data);
}
count++;
}
return count;
}
if (found == 1)
{
printf("\t %d", q->data);
}
}
}
if (found != 1)
{
printf("\t %d", p->data);
}
}
}
if (found != 1)
{
printf("\t %d", q->data);
}
}
}
int main()
{
node *head, *head1;
int ch = 0, m, count;
while (ch != 8)
{
switch (ch)
{
case 1:
printf("Students like vanilla\n");
head = createnode();
printf("Students like butterscotch\n");
head1 = createnode();
break;
case 2:
printf("Students like vanilla\n");
print(head);
printf("Students like butterscotch\n");
print(head1);
break;
case 3:
case 4:
case 5:
printf("Students like vanilla only\n");
sub1(head, head1);
break;
case 6:
printf("Students like butterscotch only\n");
sub2(head, head1);
break;
case 7:
printf("Students like neither vanilla nor
butterscotch=%d\n", m - count);
break;
case 8:
default:
printf("Invalid choice\n");
}
}
return 0;
}
Output:-
root@root123-HP-ProDesk-600-G3-SFF:/home/root123# python3
student.py
root@root123-HP-ProDesk-600-G3-SFF:/home/root123#
Name :- BHAMBARE ATHARV ACHYUT
Class :- S.E. Computer
Subject :- DSL
Roll No :- 06
#include<iostream>
#include<string.h>
#define max 50
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';
cout << endl << c << " is pushed on stack ...";
}
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];
}
str[top + 1] = '\0';
}
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 << "\nString is palindrome...";
else
cout << "\nString is not palindrome...";
}
int main() {
STACK stack;
char str[max];
int i = 0;
stack.convert(str);
stack.palindrome();
stack.reverse();
return 0;
}
Output:-
root@root123-HP-ProDesk-600-G3-SFF:/home/root123# python3
student.py
Computer Engineering
#include <iostream>
#include <stack>
#include <string>
using namespace std;
while (!st.empty()) {
postfix += st.top();
st.pop();
}
return postfix;
}
return st.top();
}
int main() {
string infix_expression;
string postfix_expression =
infixToPostfix(infix_expression);
return 0;
}
Output:-
Enter an infix expression: A*b+D
Postfix expression: Ab*D+
Result: 870
root@root123-HP-ProDesk-600-G3-SFF:/home/root123#
NAME :- BHAMBARE ATHARV ACHYUT
Class :- S.E. Computer
Subject :- DSL
Roll No :- 06
#include <iostream>
#define MAX 10
using namespace std;
struct queue {
int data[MAX];
int front, rear;
};
class Queue {
struct queue q;
public:
Queue() {
q.front = q.rear = -1;
}
int isempty() {
return (q.front == q.rear) ? 1 : 0;
}
int isfull() {
return (q.rear == MAX - 1) ? 1 : 0;
}
void enqueue(int);
int delqueue();
void display();
};
void Queue::enqueue(int x) {
q.data[++q.rear] = x;
}
int Queue::delqueue() {
return q.data[++q.front];
}
void Queue::display() {
int i;
cout << "\n";
for (i = q.front + 1; i <= q.rear; i++)
cout << q.data[i] << " ";
}
int main() {
Queue obj;
int ch, x;
do {
1.Insert Job
2.Delete Job
3.Display
4.Exit
Enter your choice : 1
Enter data :
23
1.Insert Job
2.Delete Job
3.Display
4.Exit
Enter your choice : 3
Queue contains :
23
1.Insert Job
2.Delete Job
3.Display
4.Exit
Enter your choice : 2
Deleted Element = 23
Remaining Jobs :
1.Insert Job
2.Delete Job
3.Display
4.Exit
Enter your choice : 4
Exiting Program
root@root123-HP-ProDesk-600-G3-SFF:/home/root123#
Name :- BHAMBARE ATHARV ACHYUT
Class :- S.E. Computer
Subject :- DSL
Roll No :- 06
#include<iostream>
#include<stdio.h>
#define MAX 10
using namespace std;
struct que
{
int arr[MAX];
int front, rear;
};
while (i != q.rear)
{
cout << "\t" << q.arr[i];
i = (i + 1) % MAX;
}
if (q->front == q->rear)
init(q);
else
q->front = (q->front + 1) % MAX;
return data1;
}
if (q->front == q->rear)
init(q);
else
q->rear = (q->rear - 1 + MAX) % MAX;
return data1;
}
int main()
{
struct que q;
int data, ch;
init(&q);
while (ch != 6)
{
cout << "\t\n1.Insert front"
< "\t\n2.Insert rear"
< "\t\n3.Delete front"
< "\t\n4.Delete rear"
< "\t\n5.Print"
< "\t\n6.Exit";
switch (ch)
{
case 1:
cout << "\nEnter data to insert front : ";
cin >> data;
addf(&q, data);
break;
case 2:
cout << "\nEnter the data to insert rear : ";
cin >> data;
addr(&q, data);
break;
case 3:
if (isempty(q))
cout << "\nDequeue is empty!!!";
else
{
data = delf(&q);
cout << "\nDeleted data is : " << data;
}
break;
case 4:
if (isempty(q))
cout << "\nDequeue is empty!!!";
else
{
data = delr(&q);
cout << "\nDeleted data is : " << data;
}
break;
case 5:
if (isempty(q))
cout << "\nDequeue is empty!!!";
else
{
return 0;
}
Output:-
root@root123-HP-ProDesk-600-G3-SFF:/home/root123# python3
student.py
1.Insert front
2.Insert rear
3.Delete front
4.Delete rear
5.Print
6.Exit
Enter your choice : 1
1.Insert front
2.Insert rear
3.Delete front
4.Delete rear
5.Print
6.Exit
Enter your choice : 2
1.Insert front
2.Insert rear
3.Delete front
4.Delete rear
5.Print
6.Exit
Enter your choice : 5
#include<iostream>
#include<cstdlib>
using namespace std;
class pizza {
int front, rear, q[5];
public:
pizza() {
front = -1;
rear = -1;
}
int isfull() {
int isempty() {
if (front == -1 && rear == -1)
return 1;
else
return 0;
}
void add() {
if (isfull() == 0) {
char c;
void serve() {
if (isempty() == 0) {
if (front == rear) {
cout << "\n Order served is : " << q[front];
front = -1;
rear = -1;
}
else {
cout << "\n Order served is : " << q[front];
front = (front + 1) % 5;
}
}
else
cout << "\n Orders are empty ";
}
void display() {
if (isempty() == 0) {
for (int i = front; i != rear; i = (i + 1) % 5)
cout << q[i] << "<- ";
cout << q[rear];
}
else
cout << "\n Orders are empty";
}
void check() {
int ch;
case 4: exit(0);
default:
cout << "Invalid choice ";
}
char ch1;
cout << "\n Do you want to continue?
"; cin >> ch1;
if (ch1 == 'y' || ch1 == 'Y')
check();
}
};
int main() {
pizza p1;
p1.check();
return 0;
}
Output:-
root@root123-HP-ProDesk-600-G3-SFF:/home/root123# python3
student.py
* * * * PIZZA PARLOUR * * * *
1. Add a Pizza
2. Display the Orders
3. Serve a pizza
4. Exit
Enter your choice : 2
* * * * PIZZA PARLOUR * * * *
1. Add a Pizza
2. Display the Orders
3. Serve a pizza
4. Exit
Enter your choice : 3
* * * * PIZZA PARLOUR * * * *
1. Add a Pizza
2. Display the Orders
3. Serve a pizza
4. Exit
Enter your choice : 1