0% found this document useful (0 votes)
39 views

Assignment of CS Class XII

Uploaded by

sumitkachhap5454
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Assignment of CS Class XII

Uploaded by

sumitkachhap5454
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

DAV KAPILDEV PUBLIC SCHOOL KADRU

ASSIGNMENT
(COMPUTER SCIENCE -083)
Python programs
1)Write a function add(n) to add n lines in a text file kdps.dat. Also write
a function display() which will count and display lines starting with a
vowel. Invoke these functions.

2)Write a program in python having these functions:


Add() for adding lines in “kdps.dat” and words() for counting words with
length >4 characters in each line. Invoke these functions.

3) Write a program in python having these functions:


Add() for adding lines , display() to read a text file line by line and
display each word separated by #.

4) Write a program in python having these functions:


i)add():- for adding lines.
ii)rem():- copy all lines that contain character “a” in a file to another file.

5) Write a program in python having these functions:


i)add():- for adding lines.
ii)count():- read a text file and display number of vowels , upper case,
lower case, digits and blank space in a file.

6) Write a program in python having these functions:


i)add():-for creating a binary file with name ,roll no and marks and store
n records
ii)update():- input a roll no and update the marks after updation,display
whole file.

7) Write a program in python having these functions:


i)add():- for creating a binary file with name and roll no and store n
records
ii)search()-input a roll no and display the name,if not found display
appropriate message.

8) Write a program in python having these functions:


i)add():- for adding n records in binary file. Structure[item number, item
name, unit price, quantity]
ii)display():- for displaying all records of binary file
iii)search():- to print total values for those items whose quantity >100
and also to
print quantity of such items.
iv)update():- input item number and modify unit price and quantity.
v)delete(): deleting those items where quantity is 0.
Write a menu driven program to:
1.add 2.display 3.search 4.update 5.delete 6.quit

9) Write a program in python having these functions:


i)add():- to add records to the CSV file password.csv(with file structure
[userid, passwrd])
ii)display() :-print user id and password for all users
iii)search():- to enter user id and display its password.

10)Write a menu driven program to 1.add 2.display 3.search 4.quit in a


csv file (with file structure [itno,name,price,qty]). display() fn. should
display name and price of those items where qty is less than 10.
search() fn should search if particular itno is present in the file or not.

11)Write a menu driven program to push pop and display in a stack


implemented using list of names in python.Define functions for
push,pop and display.

12)Write a program to input a list,create a stack by using user defined


function PUSH() and pushing only the even elements in the stack,also
pop and display the content of stack .

13)Write a program to simulate a dice (1 to 6) .User should be able to


throw the dice as long as he wants.
14)Write a program having function shift(l) which accept a list as
parameter. It will shift the elements right
Input: 1,2,3,4,5
Output: 5,1,2,3,4

15)Write a program having function frequency(t) which accepts a tuple


as a parameter and displays frequency of each element. Input:
(1,1,3,2,2,2,4,4,5,5)
Output: 1- 2 times
2- 3 times
3- 1 times
4- 2 times
5- 2 times

SQL commands

16.Give SQL commands for the following –


a.Create a table called “publisher” according to the information given
below–
Column Name Datatype Size Remark
pub_id varchar 8 Publisher id
pub_name varchar 50 Publisher name
pub_city varchar 25 Publisher city
country varchar 25 Country
country_name varchar 25 Name of city of head office
no_of_branch int 3 No of branches in the country
estd date Established date

b.Display the details of all publisher arranged according to country in


ascending manner.
c.Display the publisher name and no of branches who have country
offices in “India” or “Sri Lanka”.
d.Display the name of the cities and no of branches of “Penguin
Random House” in “India”.
e.Display the publishing city and country of all the publications that
were established in the year 2002.
f.Display the details of all the publishers whose publication city has ‘e’
as the 3rd character.
g.Change the country office to “Mumbai” for “Harper Collins”.
h.Increase the no of branches to 7 for “Cambridge University Press” in
“Texas”.
i.Add a column “email” of type varchar size 40.
j.Remove the details of “Alta Graphics” that has a branch office in
“Manila”.
17.Give SQL commands for the following –
Table – orders

a. Find the total purchase amount of all orders.


b. Find the number of salesmen.
c. Find maximum purchase amount of all the orders.
d. Find the highest purchase amount ordered by each customer with
their ID and highest purchase amount.
e. Find ids of those customers have placed more than 3 orders.
f. Make ord_no as primary key.
g. Remove table orders.
18.Write SQL queries for the following –
Table – TRAINER

i.Display the trainer and course names of all the courses that began in
the year 2020.
ii.Display the name and fee of the course(s) being taught by ‘Deepti’.
iii.Display the name and salary of the trainers who are taking the ‘O
Level’ course.
iv.Print the latest hired date.
v.Count the no. of courses.
vi.Display the no of trainers from each city.

19.Write SQL queries for the following –


i.Display the trainer name, course name and fee of all the courses
available in ‘Mumbai or ‘Delhi’.
ii.Display trainer name, hire date, course name and course start date of
all those courses whose fees is more than or equal to 10000 but less
than or equal to1800.
iii.Increase the salary of all trainers from Mumbai and Delhi by 10%.
iv.Print name of all trainers joined in 1994.
v.Print information of all courses started in jan. in descending order of
fees.

20)Write SQL commands for the following:-


a.Create a database “aissce”.
b.Display all its tables.
c.Create table result with attribute and constraints roll(primary
key),sub(unique),marks,grade(not null).
d.Display table structure of result.
e.Remove the column grade.
f.Change the datatype of marks from int to float.
Programs on Python-SQL connectivity

21.Design a Python application to fetch records from stud table (already


created) and print them.
22.Write a program to insert a record in a table stud.(roll,name are
attributes)
23.Write a program to add a column marks in stud table and then set
marks to 33 for a given name.
24.Write a program to give grace of 5 marks to all students who have
secured marks<33 from table stud.

You might also like