1. Input a string.
Write user defined functions which takes a string as its parameter to:
i) Display whether it is a palindrome or not.
ii) Display the string after convert the case of characters in a string.
iii) Count and display the number of vowels, consonants, uppercase, lowercase characters in string.
Also, accept a character - Split string w.r.t this character
iv) Display the string in which the repeated characters replaced with a ‘#’
Output:
2. Write a menu driven program to manipulate a list:
a) Add single element
b) Add another list to existing list
c) Delete a given element if it is present in the list
d) Search a user input element and display it’s frequency
e) Display all the elements in the same line separated with ‘@’
f) Arrange the elements in ascending and descending order and display
3. Input a list of numbers and test if a number is equal to the sum of the cubes of its digits. Find the
smallest and largest such number from the given list of numbers.
4.Write a user defined function in python to SHIFT(lst) that would accept a list as argument .The
function should shift the negative numbers of the list to right and the positive numbers to left
without using a another list. For example if list initially contains [3, -5, 1, 3, 7, 0, -15, 3, -7, -8].Then
after shifting list should contain [3, 1, 3, 7, 0, 3, -8, -7, -15, -5]
5. Write a user defined function in python to SwapHalfList(Array), which accepts a list Array of
numbers and swaps the elements of 1st Half of the list with the 2nd Half of the list ONLY if the sum
of 1st Half is greater than 2nd Half of the list. Sample Input Data of the list: Array= [ 100, 200, 300,
40, 50, 60] Output Arr = [40, 50, 60, 100, 200, 300]
6. Write following a user defined function in python to RShift(Lst) in Python, which accepts a list Lst
of numbers shifts all its elements right once. Sample Input Data of the list: Lst= [ 10,20,30,40,12,11]
Output: Lst = [ 11,10,20,30,40,12]
7. Write following a user defined function in python to LShift(Lst,n) in Python, which accepts a list Lst
of numbers and n is a numeric value by which all elements of the list are shifted to left. Sample Input
Data of the list: Lst= [ 10,20,30,40,12,11], n=2 Output: Lst = [30,40,12,11,10,20]
8. Write following a user defined function in python to lst_reverse() that reverses a list. Write the
code without slicing/built-in function. Sample list: [12,34,5,67,43] After execution of the code: [43,
67, 5, 34, 12]
9. Write following a user defined function in python to part_reverse(lst,start, end) to reverse
elements in a list where arguments are start and end index of the list part which is to be reversed. 2
Assume that, start=0 and end
10. Write following a user defined function in python to lst_modify() to read a list of elements.
Modify this list so that it does not contain any duplicate elements i.e. all elements occurring multiple
times in the list should appear only once.
11. Write following a user defined function in python to swap_loc() to swap elements at the even
location with the elements at the odd location. Sample Input Data of the list: Array= [ 100, 200, 300,
40, 50, 60] Output Array=[200,100,40,300,60,50]
12. Write a user defined random number generator function that generates random numbers
between 1 and 6 (simulates a dice) until the user stop the program.(use while loop)
13. Write a program with user defined functions
CreateWord(()- to create ‘word.txt’ file – by accepting n of lines of text from user and write it into
file using writelines().
DisplayFile()- Display number of characters and number of words in it.
14. Write a program with user defined functions CreateStory()- n lines accepted from user in a text
file story with few lines in it. DisplayWord()- Display each word separated by a ‘#’
15. Write a program with user defined functions
CreatePledge()- to create pledge.txt, containing few lines of pledge.
DisplayPledge()- Display the contents line by line (after striping leading and trailing whitespaces)
along with number of characters in each line
16. Write a program with user defined functions
CreatePoem()- to create the file poem.txt containing the following :
The woods are lovely
dark and deep
But I have promises to keep
And miles to go before I sleep
And miles to go before I sleep
DisplayPoem()- displays the n most commonly occurring words.
17. Write user-defined functions:
createText() – create the text file wisdom.txt with the following content.
My son, listen to your father's advice. Don't turn away from your mother's teaching. What they
teach you will be like a beautiful crown on your head. It will be like a chain to decorate your neck.
NoVowels(s) that accept a string as its argument and display the words that doesn’t contain any
vowels in it.
vowelWord()- that read the text file, vowelWord.txt and displays those lines which have the second
letter of the first word a vowel.
18. Write a program with user defined functions
a) crtBookFile()- for entering details of books from user and insert it in a binary file named ‘book.det
through list. Sample: [Bookid, Bookname, Authorname, Price]
b) BookPrice() –to display book details having price greater than a given price.
c) SearchBook()- Sreach and display the details of a specific book entered by user.
19. Write a user defined functions
a) MakeFile( ) to input multiple items from the user and add to binary file Items.dat which has
structure as [Code, Description, Price].
b) SearchRec(Code) in Python which will accept the code as parameter and search and display the
details of the corresponding code on screen from Items.dat. Also display number items having such
code out of total number of items.
20. Write a program with user defined functions
a) CreatEmp()- for entering details of employees from user and insert it in a binary file named
‘emp.dat’ through dictionary.
Sample record has the form {empno:[empname,job, sal],
Sample: {101:[Mark,Manager,2000]}
b) DisplayEmps()-Display the records of all employees
c) SearchEmp()-display those employees’ details whose salary is between 25000 and 30000.
25. Write a program in python for Sql connectivity Consider tables emp and dept tables:
(a) Add a column HRA with default value 2000
(b) Modify HRA for the employee whose empno is input by the user.
(c) Display name, job and annual salary of employees whose comm is assigned in descending order
of salary.
(d) Delete the record of employee whose employee number input by the user
(e) Display empno, name, job and department name who are either a manger or a clerk.
(f) Display minimum and maximum, sum and average of salary along with number of records in job
26. Write functions for Python –Sql Connectivity:
(a) List tables in your database
(b) Create Tables – Garment & Fabric. (Tables given qstn 33)
(c)Display the structure of the table Fabric
(d) Insert a Record by accepting values from user
(e) Delete record of a garment with gcode accepted from the user
(f) Modify the price of a garment with specific gcode accepted from user.
(f) Display records of tables by choice -ie., either records of garment or fabric.
32. Consider tables Garment and Fabric.
a) Display min, max, sum, and average price for each fabric codes in table Garment.
b) Find the total number of garments in each Type.
c) Increase the price of ‘SLACKS’ by 150
d) Display fabric code, description, price and type of all garments
e) Display Maximum Fabric code, minimum Ready date.
f) Display different Fabric codes.
g) Display the number of different garment codes.
h) Display number of different Fabric codes.
i) Display the name of garments whose length contains less than 7 characters.
j) Display the name of fabrics ready in 2008
k) Display Equi-join
l) Display natural join
33. Consider the table Student
a) Add columns Tot and Grade
b) Update Tot as sum of all subjects using query.
c) Using query, assign A+ Grade for those students who scored whose total mark greater than 91.
d) Delete the details of a student in the above table whose Tot mark is not assigned.
e) Display the details of the students whose average(ie., Tot/5) mark more than 80.
f) Display the min, max, sum, and average of CS marks.
g) Order the (student ID, Name &marks) table in descending order of the Tot mark.
h) Add the record - 's104','Catherine', 95,76, NULL, 74, 63.
i) Change Che =80 and Grade =’A’ for the student with id s104.
34. Consider Tables EMP and Dept
a) Display number of employees, sum and average salary in each department from tables Emp and
Dept.
b) Display Empno, Empname, and Deptno & Dname from tables Emp and Dept.
c) Display number of employees, sum and average salary in each job.
d) Display number of employees, sum and average salary in each job where number of employees
less than 2.
e) Display the name of senior most employee.
f) Display minimum salary and last hiring date.
g) Display average commission from the table Employee.
h) Display different jobs
i) Display number of different jobs.
35. Consider Tables : Flights & Fares
Write commands to display:
a) Fl_No and No_Flights from Kanpur to Bangalore.
b) Arrange the contents of flights in descending order of Fl_No.
c) Display Fl_No, Airlines and Fare to be paid for the flights from Delhi to Mumbai from tables flights
and Fares where Fare to be paid=Fare+ Fare* Tax/100.
d) Minimum fare Indian Airlines offering from table Fares.
36. Consider Table: Furniture
Write commands to display:
a) information about the Baby Cots
b) Item name which are priced at more than 15000.
c) Item name and Type in which date of stock before 22-01-2002 in descending order of Item name.
d) Item name and date of stock of those items in which discount percentage is more than 25.
e) Count number of items whose type is ‘sofa’.
f) insert a row: 14, Velvet Touch, Double Bed, 25-03-2003,25000,30
g) Display the number of different types in table furniture.
h) Display the maximum and average discount of the type ‘Baby cot’ and date of staock is less than
’2002-02-12’;