0% found this document useful (0 votes)
33 views7 pages

Practical File Questions

The document outlines a series of practical programming tasks and SQL commands aimed at enhancing students' understanding of Python and database management. It includes exercises on prime-Adam integers, frequency of digits, palindrome checking, and various database operations such as creating tables, updating records, and querying data. Additionally, it covers the implementation of a computerized Arabic-English dictionary and student management systems using Python and SQL.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views7 pages

Practical File Questions

The document outlines a series of practical programming tasks and SQL commands aimed at enhancing students' understanding of Python and database management. It includes exercises on prime-Adam integers, frequency of digits, palindrome checking, and various database operations such as creating tables, updating records, and querying data. Additionally, it covers the implementation of a computerized Arabic-English dictionary and student management systems using Python and SQL.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

S.

Practical’s Name Page Teacher


No. No. ’s
Sign
1 A Prime-Adam integer is a positive integer
(without leading zeros) which is a prime as well
as an Adam number.
Prime number : A number which has only two
factors, i.e. 1 and the number itself.
Example: 2, 3, 5, 7 …etc.
Adam number: The square of a number and the
square of its reverse are reverse to each other.
Example: If n=13 and reverse of ‘n’ =31, then,
(13)2 = 169
(31)2 = 961 which is reverse of 169
thus 13, is an Adam number.

2 WRITE A PROGRAM to accept a number and display


the frequency of each digit present in the
number:
sample input:341124
sample output: The
frequency of 1=2

The frequency of 4=2


The frequency of 3=1
The frequency of 2=1
.
3 Write a program in Python which accepts a list of
n integers and assign the elements into a two
dimensional table of integers in the following
format(size must be odd)

If the list is 1 2 3 4 5

The output must be


1 2 3 4 5
1 2 3 4 0
1 2 3 0 0
1 2 0 0 0
1 0 0 0 0

4 Develop a Python function to check if a number is


a Smith number. A Smith number is a composite
number whose sum of digits is equal to the sum of
the digits of its prime factors.
Example: 4, 22, 27, 58, 85, 94, 121 …

5 Given a non-empty string s, you may delete at


most one character. Judge whether you can
make it a palindrome. For example, input:
"abca", the function should return true
because you can remove the 'b' to form a
palindrome.

6 N students have to take an exam in an examination


hall. Roll numbers of these students are from
91041 to 91090. The invigilator in the
examination hall has to maintain a list of roll
numbers of all the
students present in the hall at any moment. For
this we have to write a program for the
invigilator
which will allow him/her to:
(i) Enter roll numbers of students as they enter
the hall (one student at a time). While entry:
a. Only valid roll numbers should be allowed
b. No duplicate roll numbers should be allowed
(ii) Delete the roll number of any student who
leaves the hall
(iii) Display the number of students present in
the hall at any moment
(iv) Display the smallest and the largest roll
number present in the hall
(v) Display a list of absentees’ roll numbers
(vi) Display a sorted list of roll numbers
present
7 Write a program To create two tuple A and B and
sort them in ascending order. Then, merge the
contents of A and B into a third tuple C, where C
is also required to be in ascending order. Then
display the tuples A, B, and C.
8 To improve the vocabulary of students, an Arabic
teaching institute is planning to introduce a
computerized Arabic-English-Arabic dictionary
with the following features: (i) To display the
Arabic translation of an English word (ii) (iii)
(iv) (v) (vi) (vii) To display the English
translation of an Arabic word. If an English word
is not found in the dictionary, it should be
placed in a tuple so that the teachers can later
update the dictionary. Point number (iii) for
Arabic words. To display a tuple of English words
not found in the dictionary. Point number (v) for
Arabic words. To update the dictionary. Only an
authorized teacher should be able to update the
dictionary. Therefore, update dictionary must be
preceded by a password check. Initially the
dictionaries will contain the following enteries:

Develop a Python script to do the desired task.


9 The roll numbers, names, and marks of n
students of a class have to be stored in a
list. Then the details of all the students are
to be displayed in alphabetical order by their
names. Write a Python program to do this. Use
insertion sort to sort the data.
10 Write a program to create a list of student names
and aggregate percentage, where each student’s
data is represented as a dictionary with keys
name and marks. Then sort this list in ascending
order of names (using bubble sort) and display
the list along with each student’s result. Result
is ‘Pass’ if aggregate marks are more than 39,
otherwise the result is ‘Fail
11. Assuming the class PICNIC given below, write a
menu driven program with separate functions in
Python to perform the following:

{ “Location”:_________,”No_of_members”:____,
”Date”:_____}

a) write details(records) of PICNIC to a


binary file
b) Sort the file on location
c) display the sorted file

12 A junior college in Mumbai consists of only


classes 11 and 12, at the year end the 12th class
students pass out( except those who have failed)
and the class 11 students are promoted to class
12. consider the following record definition and
perform the following operations using separate
functions:
{ “Roll”:_____,”Name”:____,”Status”:____,”Clas
s”:____}
Write a menu driven program to perform the
following tasks:
a) a function to write new objects in the file
college.dat.
b) a function to display the contents of the
file college.dat
c) a function to delete all the records for the
students who are in class 12 except those
whose status is “F”(fail)
d) a function to update file college.dat i.e.
to remove all records with status as “F”,
write them into a separate file called
“failure.dat and simultaneously change all
class 11 to 12( in the file “college.dat)

13. The dictionary Applicant contains the following


data
name of the applicant, State, telephone
number

Write a function that saves the above object to a


file registration.dat. Save 10 records.
Now create a file Allot.dat which is maintained
to hold the details of person seeking
registrations for new cars. The details
maintained are which are saved in a file
Registration.dat. The registration is provided on
the basis of first cum first serve basis. Each
time RTO office provides registration to five
persons which are picked from the file and
populated in the Allot.dat. Display details of
people along with registration number allotted to
them. (The Registration number given will be
starting with two beginning alphabets from state
in capital case followed by last four digit from
telephone number of the applicant)

14. Create a csv file using MS-Excel with the


following data:
Name, Age, Qualification, Experience
Ananya,32,PG,8
Then, write a menu driven program to perform the
following operations on the file:
(i) Append record(s) to the file
(ii) Display all the data from the file
(iii) Display all the records with Age<30
(iv) Increase the Experience of all the records
by 1
(v) Delete a record with given name and age (to
be input from the user)
.
15. Jomia has created the following dictionary
containing Indian names of some herbs and their
corresponding names in English:
Herbs={'Adrak':'Ginger', 'Amla': 'Gooseberry',
'Babool': 'Indian Gum', 'Dhania': 'Coriander',
'Lahsun':'Garlic', 'Tulsi': 'Basil'}
Write a program to add those key value pairs
where the corresponding value (English name)
starts with 'G'. Write separate user defined
functions to perform the following operations:
a. DPush- the item (key, value pair) into a
stack,
b. DPop- to remove a key value pair from the
stack
c. Display- to show the content of the stack
(top to bottom)
.
S. Practical’s Name Page Teacher’s
No. No. Signature

1 Create a student table (ADMNO, CLASS-SEC, NAME,


SCORE) and insert data. Implement the following
SQL commands on the student table:
 ALTER table to add new attributes (SEX
CHAR(1) / modify data type CHAR to
VARCHAR/ drop attribute SEX
 UPDATE table to modify data- Increase the
marks of all students by 10 who scored
less than 20.
 ORDER BY to display data in ascending /
descending order by (i) NAME wise (ii)
SCORE wise
 DELETE to remove tuple(s) having SCORE less
than 10.
 GROUP BY and find the min, max, sum, count
and average
2 Create a EMPLOYEE table (EID, NAME, SALARY,
DEPT) and insert data. Implement the following
SQL commands on the student table:
 ALTER table to add new attributes – HRA
INT(5) / modify data type of HRA to decimal
/ drop attribute HRA
 UPDATE table to modify data – increase the
salary by 10%
 ORDER BY to display data in ascending /
descending order (i) SALARY wise (ii)
EID wise
 DELETE to remove tuple(s) – employee having
emp id 101
 GROUP BY and find the min, max, sum, count and
average.
3  Create a Database LIBRARY.
 Create a table BOOKs (book_id (PK),
book_name, author_name, publishers,
price, type, qty) and Insert records
 Create a table ISSUED(issue_id, book_id
(FK), quantity_issued ) and Insert records.
 Write the SQL queries –
 To show Book name, Author name and
Price of books of First Publ.
publishers. [SELECT, WHERE]
 To list the names from books of Text type.
[SELECT, WHERE]
 To display the names and price from
books in ascending order. [ORDER BY]
 To increase the price of all books
of EPB publishers by 50. [UPDATE]
 To display the Book_Id, Book_Name. and
Quantity_Issued for all books which have
been issued. [JOIN QUERY]
 To display the list of books having
publisher value is NULL.
 To display the unique name of all
Publishers.
 To display the Maximum and Average Price
of Books Publisher wise.
 Write the Output of the following queries
based on the above tables.
 SELECT COUNT(*) FROM BOOKS;
 SELECT MAX(PRICE) FROM BOOKS WHERE
QUANTITY
>= 15;
 SELECT BOOK_NAME, AUTHOR_NAME FROM
BOOKS WHERE PUBLISHERS = “EPB”;
 SELECT COUNT(DISTINCT PUBLISHERS) FROM
BOOKS WHERE PRICE >= 400;
4  Create a Database COMPANY.
 Create a table JOB (JOBID (PK), JOBTITLE,
SALARY) and Insert Records.
 Create a table Employee (EID (PK), NAME,
SALES, JOBID (FK)) and Insert Records
 Write the SQL Queries for the following:
i. To display employee ids, names of
employees, job ids, with
corresponding job titles. (JOIN
QUERY)
ii. To display names of employees, sales and
corresponding job titles who have
achieved sales more than 130000. (JOIN
QUERY)
iii. To display names and corresponding job
titles of those employees who have
‘SINGH’ (anywhere) in their names.
iv. Display the name of employee having
maximum salary.
v. Write the SQL command to change the
JobId to 104 of the Employee with ID
as E4 in the table EMPLOYEE.
5  Create a Table CLUB (CoachId, CoachName, Age,
Sports, DateofApp, Pay, Sex) and Insert
Records.
 Write the SQL Queries for the following: -
 To display the list of coach who is
playing KARATE.
 To display the records having Pay between
500 to 1000.
 To display the names of coach whose name
starts with ‘A’.
 To display the total salary paid to Coach
Gender wise.
 To display all records alphabetically on
name.
 Give the output of following SQL statements: -
 SELECT COUNT(DISTINCT SPORTS) FROM CLUB;
 SELECT MIN(AGE) FROM CLUB WHERE SEX = ‘M’;
 SELECT AVG(AGE) FROM CLUB GROUP BY SEX;
 SLEECT SUM(PAY) FROM CLUB WHERE
DATEOFAPP > ’31-03-1998’
S. Practical’s Name Page No. Teacher’s
No. Signature

1 Write a Python Program to create a Database


named “School”. Display the List of
Databases available in MySQL.
2 Write a Python program to Create a Table name
“Student” under database “School”
contained RollNo, Name, UT1, and UT2
score.
Note: UT1 and UT2 out of 40 only.
3 Write a Python Program to Insert Records in
“Student” table. Display all records.
Note: UT1 and UT2 out of 40 only
4. Write a Python program to increase the marks
of UT1 by 10 of those students having UT1
marks less than 20. Also display a message
how many records are updated.
5. Write a Python programs to Display Records
form table “Student” with their Total
Marks and Percentage.
(totalmarks = UT1 + UT2) (percentage =
totalmarks / 80 * 100

You might also like