Doc1cs1213 1
Doc1cs1213 1
VIDHAYALAYA 9BRD
SIGNATURE OF PRINCIPAL
Index
TABLE OF CONTENT
S NO. CONTENT DATE TEACHERS’S
SIGNATURE
1. Write a program to generate a prime number of 03/07/24
a given range
Output 2
3. Write a python function that takes two strings
and check whether they are anagrams of each
other
Output 3
4. Write a python function that generates a random
list and fine maximum and minimum number
without built in functions like max() and min()
Output 4
5. Write a menu-based Python program that allows you to manage a simple student grades
system using Dictionary. Your program should perform the following tasks: 1. Add few
student with their name and marks for three subjects (CS,IP,AI). 2. Display all students and
their marks. 3. For each student, calculate and display their average marks. 4. Allow the
user to update the marks for a particular student. 5. Allow the user to remove a student
from the system. 6. Allow the user to exit the program.
Output 5
6. Create a binary file with roll number, name and class and insert 3
records in it in the format [roll-no, name, class]. Search for a given roll
number and display the name, if not found display appropriate
message.
Output 6
7. Create a binary file with book, shelf_no and author. Insert 3 values-
{“Harry Potter”:[1, “J.K. Rowling”]}, {“Sherlock Holmes”:[2, “Conan
Doyle”]}, {“Time Machine”:[1, “H.G. Wells”]}. The program should
display all the book names to the user and prompt them to enter the
name of a book they wish to delete. After that, the program should ask
the user to modify the details of one of the remaining book entries.
Output 7
8. Create a CSV file (login.csv) by entering user-id and password and write
a menubased python program to perform the following task. Read-
Read and search the password for given user-id. Update- The program
asks the user to modify the details of the given user-id. Delete- Prompt
user to enter the user-id they wish to delete.
Output 8
9. Write a Python program that reads a text file and counts the number of
lines, words, and characters in the file. Display the counts in the
following format: Lines: X, Words: Y, Characters: Z.
Output
10. Write a menu-based python program to perform the following questions. Write the
definition of a user-defined function ‘push_even(N)’ which accepts a list of integers
in a parameter ‘N’ and pushes all those integers which are even from the list ‘N’
into a Stack named ‘EvenNumbers’. Write function pop_even() to pop the topmost
number from the stack and returns it. If the stack is already empty, the function
should display "Underflow". Write function disp_even() to display all element of
the stack without deleting them. If the stack is empty, the function should display
'Empty Stack’
Output 10
Q11. Perform the following SQL queries
i. Write a SQL query to create a table named Library with columns BookID,
Title, Author, Genre, PublishedYear, and CopiesAvailable and. And perform
the following questions
ii. Write SQL queries to insert at least three records into the Library table.
iii. Write a SQL query to update the number of available copies of a specific
book (e.g., increase by 2).
iv. Write a SQL query to delete a book record from the Library table where the
BookID is a specific value.
Q12. Perform the following SQL queries i. Create two tables: Students (with
columns StudentID, Name, Age, Class) and Marks (with columns StudentID,
Subject, Score). Ensure that StudentID in Marks references StudentID in
Students.
I. Write SQL queries to insert at least three records into both the Students and
Marks tables.
II. Write a SQL query to find the average score of each student across all
subjects and display the results with student names.
III. Write a SQL query to delete a record from the Marks table for a student
who has withdrawn from a subject.
IV. Write a SQL query to count the total number of students in each class.
Q 13. Create the table ORDERS as given below and perform the following queries:
(I) Display the total Quantity for each Product, excluding Products with total
Quantity less than 2
(II) Display the orders table sorted by total price in descending order.
(III) Display the distinct customer names from the Orders table.
(IV) Display the sum of Price of all the orders for which the quantity is less than 2.
Q 14. Karan has been entrusted with the management of Law University Database. He
needs to access some information from FACULTY and COURSES tables for a survey
analysis. Create both the tables and help him extract the following information by
performing the desired SQL queries as mentioned below
I. To display complete details (from both the tables) of those Faculties whose
salary is less than 12000.
II. To display the details of courses whose fees is in the range of 20000 to 50000
(both values included).
III. To increase the fees of all courses by 500 which have "Computer" in their
Course names
IV. To display names (FName and LName) of faculty taking System Design.
Q15. Create the table and , write SQL queries for the following
II. Write a SQL statement to change the data type of the salary column in the
employees table from INT to DECIMAL(10, 2).
III. Write a statement to add a new column named date_of_birth of type DATE.
Write a menu based program to perform the tasks given in the following questions(Q16-
Q20).
Q16.Write a Python program to connect to a MySQL database named SchoolDB.
Q17. Write a SQL query to create a table named Students with the following columns:
StudentID, Name, Age, and Class. Execute this query using a Python script.
Q18. Create a Python program that retrieves all records from the Students table and
displays them in a formatted manner.
Q19. Write a Python program that updates the age of a specific student in the Students
table based on StudentID.
Q20. Write a Python program that deletes a record from the Students table where the
StudentID is a specific value
Output