0% found this document useful (0 votes)
32 views4 pages

Comp Rec Qs

The document contains 20 programming problems involving user-defined functions, file handling, database operations, and SQL commands. Some of the problems involve: 1. Defining functions to check if a number is Armstrong/perfect, find palindromes, duplicates in a list, and prime numbers in a list. 2. Reading and analyzing text files to count characters and find longest/matching words. 3. Implementing stack operations using lists and dictionaries to push, pop, and display customer/vehicle details. 4. Creating a database with a table to store store items, adding/modifying records, and running queries to display, filter, order, and aggregate records. 5. Defining

Uploaded by

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

Comp Rec Qs

The document contains 20 programming problems involving user-defined functions, file handling, database operations, and SQL commands. Some of the problems involve: 1. Defining functions to check if a number is Armstrong/perfect, find palindromes, duplicates in a list, and prime numbers in a list. 2. Reading and analyzing text files to count characters and find longest/matching words. 3. Implementing stack operations using lists and dictionaries to push, pop, and display customer/vehicle details. 4. Creating a database with a table to store store items, adding/modifying records, and running queries to display, filter, order, and aggregate records. 5. Defining

Uploaded by

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

'''1.

A menu driven program in Python that accepts a number and displays the
following
options:
(a) Pass number as argument and check if it is an Armstrong number or not.
(b) Pass number as argument and check if it is Perfect number or not.
'''

'''2. A Python program implementing user defined function PALLINDROME() that


accepts a
string as argument and return 1 if the string is palindrome else return -1.
'''

'''3. A Python program implementing user defined function to find the duplicate
elements in
a list given by the user.
'''

'''4. A Python program implementing user defined function that accepts a list as
argument and
display all the prime numbers in the list.
'''

'''5. Python program that accepts ‘n’ integers to a tuple and returns all the even
numbers
divisible by 7.
'''

'''6. A Python program implementing function num_generator() that accept N, X, Y as


arguments. The function should generate ‘N’ random numbers with the range X and Y
and
return the generated numbers as a list and display them.
'''

'''7. Python program to read a text file ‘story.txt’ and display the number of
vowels,
consonants, digits, lower-case, upper-case characters.
'''

'''8. Python program to read a text file ‘Details.txt’ and display the longest word
in the file.
Also display the words ending with lowercase vowels in the file.
'''

'''9. Python program to copy the lines that starts with ‘The’ from a text file into
another text
file ‘Copy.txt’. The name of the text file should be entered by the user at run
time.
'''

'''10. A binary file ‘company.dat’ stores following information about the employees
of a
company [EMPID, ENAME, BASIC, HRA, PF, NETPAY]. HRA is calculates as 5% of
BASIC, PF is 20% of BASIC, NETPAY is calculated as BASIC + HRA – PF.
Write a Python program implementing function Del_details() that deletes the details
of
the Employee whose name is entered by the user.
'''

'''11. Write a Python program to store the festivals of various states to a binary
file
‘Festivals.dat’ in the following format:
Festival ={State_name: [festival_name, tourist_destination]}
Use a menu driven program to:
• Store the festivals, tourist_destination of 5 states.
• Display the name of the festival, tourist_destination if the state_name is
entered.
• Add festivals, tourist_destination of 3 more states.
• Display all the records.
'''

'''12. Create a python program to add and update/modify records in binary file
‘OPTION.DAT’
having the following structure {Name: [Game, SUPW]}
(i) Add ‘n’ records to the table
(ii) Modify the Game if the name of a student is entered
'''

'''13. Write a Python program to store the details of flights in a binary file
‘Flight.dat’ in the
following format:
Flight_Record ={Flight_no: [From, Destination, Arrival, Departure]}
Use a menu driven program to:
• Display the details of the flight if the Flight_No is entered.
• Update the flight’s arrival time or departure time
• Delete the details of the Flight if the Flight_No is entered
• Display all the details of Flights ‘From’ Delhi.
'''

'''14. Creating a python program that defines and calls the following user defined
functions:
(i) Add_Book() : Takes the details of the books and adds them to CSV FILE
‘Book.csv’. Each record consists of a list with fields Book_id, BName,
Publisher.
(ii) Search() : Takes Publisher name as argument and counts and displays number
of books published by them.
'''

'''15. Python program to implement stack operations (Using List).


The List contains the following record of customer – [Customer Name,
Account no, Account Type]
The program should have the following user defined functions to perform given
operations of the stack named ‘Bank’
(i) Pust_Cust() – To push the Customer’s name and Account no of those
customers whose account type is ‘Savings’
(ii) Pop_Cust() – To pop the details of the customers from the stack and display
them. Also display “Underflow” when there are no customers in the stack.
(iii) Display() – To display all the details of the customers in the stack.
'''

'''16. Python program to implement stack operations (Using Dictionary).


The dictionary contains details of vehicles - {Car_name: Manufacturer model}
The program should have the following user defined functions to perform given
operations of the stack named ‘Vehicle’
(i) Pust_Veh() – To push the name of car manufactured by ‘TATA’ to the stack.
(ii) Pop_Veh() – To pop the details of the cars from the stack and display them.
Also display “Underflow” when there are no customers in the stack.
(iii) Display() – To display all the details of the cars in the stack.
'''
'''17. Write a Python program to create a database – mystore. Use this database and
create a
table with the following details:
User Name - root
Password - toch
Name of the table - STORE
• The attributes of STORE are as follows:
ItemNo – numeric which is a Primary key,
ItemName – character of size 20 which should not be null,
Scode – numeric,
Quantity – numeric by default the value should be set as 0
(a) Display the message “Table Created” after creating the table.
(b) Add 4 records to the table.
'''

'''18. Write a Python program to do the following:


(a) display all data of records two to four from the table STORE.
(b) display the item_no, ItemName of all items whose Scode is either 22 or 23.
'''

'''19. Write a Python program to do the following using the table STORE:
(a) Change the quantity of given item, if the Item_No and new quantity is entered
by the
user.
(b) Display all the records in descending order of item_no.
'''

'''20. Write a Python program to delete the record whose Scode is 21 and display
the remaining
records in the table STORE.
Also, display the total number of records in the table.
Item_no ItemName Scode Quantity
101 Sharpener Classic 23 60
103 Ball Pen 0.25 22 50
102 Gel Pen Premium 21 150
104 Gel Pen Classic 21 250
'''

'''21. Write SQL commands and their outputs based on the given tables:
Table: MOVIE_DETAILS
MOVIEID TITLE LANGUAGE RATING PLATFORM
M001 Minari Korean 5 Netflix
M004 Spiderman, No way Home English 4 Hotstar
M010 Kaagaz Hindi 3 Zee5
M011 Harry Potter and the Chamber of Secrets English 4 Prime Video
M015 2018 Malayalam 5 Hotstar
M020 Avengers: Endgame English 4 Hotstar
M019 The Magician' Elephant English 3 Disney
Table: SCHEDULE
SLOTID MOVIEID TIMESLOT
S001 M010 10 AM
S002 M020 2 PM
S003 M010 6 PM
S004 M011 9 PM
S005 M019 NULL
1. Create the Table MOVIE_DETAILS with the following specifications
MOVIEID char(5) set as Primary key,
TITLE varchar(25) set as not null,
LANGUAGE varchar(10)
RATING integer
PLATFORM varchar(10)
2. Add a record ‘M011’, ‘Harry Potter and the Chamber of Secrets’, English, 4,
Prime Video to
the table MOVIE_DETAILS.
3. Display the structure of the table MOVIE_DETAILS.
4. Display the number of languages without redundancy.
5. Display the MovieID, MovieNames, Language of movies with rating 4
6. Display the names of the platforms without redundancy.
7. Display the names of the Platform with the letter ‘s’ in it.
8. Display the names of the movies in descending order of rating.
9. Display the minimum & maximum rating of movies.
10. Display the movieid, moviename, timeslot of movies in the platform ‘Hotstar’.
11. Count the total number of movies under each rating.
12. Display the Slotid,movieid, moviename of movies that is scheduled in the
afternoon
13. Change the Platform of M004 to “Prime Video”.
14. Display the details of MovieID, SlotID whose Timeslot is not NULL.
15. Add a column Moviedt of date type to the table SCHEDULE.
16. Delete the movie from the Korean Language.
17. Set the Column SLOTID in the table SCHEDULE as Primary Key.
18. Make MOVIEID in SCHEDULE table as the foreign key with reference to
MOVIE_DETAILS
table.
19. Delete the table SCHEDULE.
20. Delete the database.
'''

You might also like