List of Practical - CS - Class 12
List of Practical - CS - Class 12
18. Write a menu driven program in python to input 10 numbers in a stack S. Then give the user
thefollowing choices.
If he/she input 1, the number in which are divisible by 5, will be added in a new stack named
new_S.
If the user inputs 2, the number which are divisible by 7 will be inserted in new.
Also display both the stack if the user input 3.
If the user input 4 then it shall display the the top most element of the newly created stack new_s
and new.
Use function push( ), pop( ),peep( ) and display( ) to create the same.
19. Write a program to create a stack named BooksStack that contains records of books.
Each book record is represented as a list containing book_title, author_name, and
publication_year.
Write the following user-defined functions in Python to perform the specified operations on the
stack BooksStack:
(I) push_book(BooksStack, new_book): This function takes the stack BooksStack and a new
book record new_book as arguments and pushes the new book record onto the stack.
(II) pop_book(BooksStack): This function pops the topmost book record from the stack and
returns it. If the stack is already empty, the L function should display "Underflow".
(III) peep(BookStack): This function displays the topmost element of the stack without
deletingit. If the stack is empty, the function should display 'None'.
20. Write a program to create a stack of odd numbers out of all the numbers given by the user.
Display the content of the stack along with the largest odd numbers in the stack.
21. Write a program in python to take the names of 4 students in a stack called Student. Display the
name of the students whose names start with M. Also delete the names of the students who has
less than 4 letters in their name from Student and insert them in a new stack Student2
22.
Roll Name Mark
s
1 Anish 40
2 Neel 60
3 Arpita 80
Write a python MySQL connection program to create the above table. And execute the following
query
a. Increase the marks of the students by 20 whose name starts with A.
b. Change the column name from Name to Student_Name
c. Drop the primary key attribute of the Roll
d. Insert one more record (4,”Abhay”,20)
e. Delete the details of the student who got less than 50
23. Write a python MySQL connection program to create the table and execute the queries