0% found this document useful (0 votes)
65 views10 pages

Final Board Practicals 2023-2024 CS Programs

The document contains information about Python and SQL programs related to various tasks. The Python programs include: 1) A program to perform arithmetic operations on two input numbers and print the results 2) A program to read data from a user and write it to a binary file 3) A program to read a text file and count the vowels, consonants, uppercase and lowercase letters The SQL questions involve: 1) Creating tables and inserting values, displaying data based on conditions, updating and deleting records 2) Performing queries like finding minimum/maximum salaries, calculating average, ordering and grouping data

Uploaded by

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

Final Board Practicals 2023-2024 CS Programs

The document contains information about Python and SQL programs related to various tasks. The Python programs include: 1) A program to perform arithmetic operations on two input numbers and print the results 2) A program to read data from a user and write it to a binary file 3) A program to read a text file and count the vowels, consonants, uppercase and lowercase letters The SQL questions involve: 1) Creating tables and inserting values, displaying data based on conditions, updating and deleting records 2) Performing queries like finding minimum/maximum salaries, calculating average, ordering and grouping data

Uploaded by

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

SET 1

Q1. PYTHON 8 Marks


Write a Python Program that has a dictionary containing top players and their runs as
key value pairs of cricket team. Write a program, with separate user defined functions to
perform the following operations:
Push the keys (name of the players) of the dictionary into a stack, where the
corresponding value (runs) is greater than 49.
Pop and display the content of the stack.

SOURCE CODE:
SCORE={"KAPIL":40,"SACHIN":55 , "SAURAV":80,"RAHUL":35, "YUVRAJ":110
}
def PUSH(S,R):
S.append(R)
def POP(S):
if S!=[]:
return S.pop()
else:
return None
ST=[ ]
for k in SCORE:
if SCORE[k]>49:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else:
break

OUTPUT:
YUVRAJ SAURAV SACHIN
Q2. MySQL 4 Marks
Consider the following table ‘Doctor’.

No Name Age Department Dateofadmin Charge Sex


1 Arpit 62 Surgery 21/01/06 300 M
2 Zayana 18 ENT 12/12/05 250 F
3 Kareem 68 Orthopedic 19/02/06 450 M
4 Abhilash 26 Surgery 24/11/06 300 M
5 Dhanya 24 ENT 20/10/06 350 F
Write SQL commands for the following:
1. Create the above table DOCTOR and insert the values mentioned.
CREATE TABLE DOCTOR (NO INT, NAME VARCHAR (20), AGE INT,
DEPARTMENT VARCHAR (20), DOJ DATE, CHARGE INT, SEX CHAR
(1));

2. Group & Display all the details of doctor according to their gender.
SELECT * FROM DOCTOR GROUP BY SEX;

Write SQL output based on the given query:


3. DELETE FROM DOCTOR WHERE NO = 3;
No Name Age Department Dateofadmin Charge Sex
1 Arpit 62 Surgery 21/01/06 300 M
2 Zayana 18 ENT 12/12/05 250 F
4 Abhilash 26 Surgery 24/11/06 300 M
5 Dhanya 24 ENT 20/10/06 350 F

4. SELECT NAME, AGE, DEPARTMENT FROM DOCTOR WHERE NAME


LIKE ‘%A’;
NAME AGE DEPARTMENT
ZAYANA 18 ENT
DHANYA 24 ENT
SET 2

Write a Python Program to get student data (rollno,name,marks) from user and write
onto a binary file. The program should be able to get data from the user and write onto
the file as long as the user wants.

SOURCE CODE:
import pickle
stud={}
stufile=open("stud.dat","wb")
ans='y'
while ans=='y':
rno=int(input("Enter the Roll number:"))
name=input("Enter the Name of the Student:")
marks=float(input("Enter marks:"))
stud['Rollno']=rno
stud['Name']=name
stud['marks']=marks
pickle.dump(stud,stufile)
ans=input("Want to enter more records? (Y/N)-")
stufile.close()

OUTPUT:
Enter the Roll number:11
Enter the Name of the Student:Gokul
Enter marks:83.5
Want to enter more records? (Y/N)-y
Enter the Roll number:12
Enter the Name of the Student:Mano
Enter marks:81.5
Want to enter more records? (Y/N)-y
Enter the Roll number:13
Enter the Name of the Student:James
Enter marks:80
Want to enter more records? (Y/N)-N
Q2. MySQL 4 Marks
Consider the table ‘EMPLOYEES’
NO NAME DEPARTMENT DATE OFJOINING SALARY SEX
1 RAJA COMPUTER 21/05/1998 8000 M
2 SANGILA HISTORY 21/05/1997 9000 F
3 RITU SOCIOLOGY 29/08/1998 8000 F
4 KUMAR LINGUISTICS 13/06/1996 10000 M
5 VENKATRAMAN HISTORY 31/10/1999 8000 M
6 SIDHU COMPUTER 21/05/1986 14000 M
7 AISWARYA SOCIOLOGY 11/01/1988 12000 F
Write SQL commands for the following:
1. Write a query to display the lowest salary of teacher in all the departments.
SELECT MIN (SALARY) AS 'LOWEST SALARY' FROM EMPLOYEES;

2. Write a query to display the highest salary of male teachers.


SELECT MAX (SALARY) AS 'HIGHEST SALARY' FROM EMPLOYEES
WHERE SEX = 'M';

Write SQL output based on the given query:


3. SELECT AVG (SALARY) AS 'AVERAGE SALARY' FROM
EMPLOYEESWHERE DOJ < '1998/01/01';
AVERAGE SALARY
11250

4. UPDATE EMPLOYEES SET SALARY = SALARY + (SALARY *0.10)


WHERE DEPARTMENT = 'COMPUTER';
NO NAME DEPARTMENT DATE OFJOINING SALARY SEX
1 RAJA COMPUTER 21/05/1998 8800 M
2 SANGILA HISTORY 21/05/1997 9000 F
3 RITU SOCIOLOGY 29/08/1998 8000 F
4 KUMAR LINGUISTICS 13/06/1996 10000 M
5 VENKATRAMAN HISTORY 31/10/1999 8000 M
6 SIDHU COMPUTER 21/05/1986 15400 M
7 AISWARYA SOCIOLOGY 11/01/1988 12000 F
SET 3

Q1. PYTHON 8 Marks


Write a Python Program to receive two numbers in a function and return the results of
all arithmetic operations(+,-,*,/,%) on these numbers

SOURCE CODE:
def arCalc(x,y):
return x+y,x-y,x*y,x/y,x%y
print("ARITHMETIC OPERATIONS")
num1=int(input("Enter number 1:"))
num2=int(input("Enter number 2:"))
add,sub,mul,div,mod=arCalc(num1,num2)
print("Sum of given numbers:",add)
print("Subtraction of given numbers:",sub)
print("Product of given numbers:",mul)
print("Division of given numbers:",div)
print("Modulo of given numbers:",mod)

OUTPUT:
ARITHMETIC OPERATIONS
Enter number 1:4
Enter number 2:7
Sum of given numbers: 11
Subtraction of given numbers: -3
Product of given numbers: 28
Division of given numbers: 0.5714285714285714
Modulo of given numbers: 4
Q2. MySQL 4 Marks
Consider the following table ‘ACTIVITY’

ACTIVITY PARTICIPANTS PRIZE SCHEDULE


ACODE STADIUM
NAME NUM MONEY DATE
RELAY STAR
1001 16 10000 23-JAN-04
100x4 ANNEX
STAR
1002 HIGH JUMP 10 12000 12-DEC-03
ANNEX
SUPER
1003 SHOT PUT 12 8000 14-FEB-04
POWER
LONG STAR
1005 12 9000 01-JAN-04
JUMP ANNEX
DISCUSS SUPER
1008 10 15000 19-MAR-04
THROW POWER
Write SQL commands for the following:
1. Write a query to display the names of all the activities with their Acode in
descending order.
SELECT ACTIVITYNAME FROM ACTIVITY ORDER BY ACODE DESC;

2. Write a query to display the activity names, Acode in ascending order of prize
money who is in ‘Star Annex’ stadium.
SELECT ACTIVITYNAME, ACODE FROM ACTIVITY WHERE STADUIM
= ‘STAR ANNEX’ ORDER BY PRIZE_MONEY;
Write SQL output based on the given query:
3. SELECT SUM (PARTICIPANT_NUM) AS 'TOTAL' FROM ACTIVITY
WHERE PRIZE_MONEY > 9000;
TOTAL
36
4. ALTER TABLE ACTIVITY ADD CITY VARCHAR(20);
ACTIVITY PARTICIPANTS PRIZE SCHEDULE
ACODE STADIUM CITY
NAME NUM MONEY DATE
RELAY STAR
1001 16 10000 23-JAN-04 NULL
100x4 ANNEX
HIGH STAR
1002 10 12000 12-DEC-03 NULL
JUMP ANNEX
SUPER
1003 SHOT PUT 12 8000 14-FEB-04 NULL
POWER
LONG STAR
1005 12 9000 01-JAN-04 NULL
JUMP ANNEX
DISCUSS SUPER
1008 10 15000 19-MAR-04 NULL
THROW POWER
SET 4

Q1. PYTHON 8 Marks


Write a Python Program to read a text file and display the number of vowels/
consonants/ uppercase/lowercase characters in the file.

SOURCE CODE:
fileobj=open("vowels.txt","r")
vowel=0
consonants=0
upper=0
lower=0
L=fileobj.read()
vowels=['a','e','i','o','u','A','E','I','O','U']
for i in L:
if i.isalpha():
if i.islower():
lower+=1
if i.isupper():
upper+=1
if i in vowels:
vowel+=1
else:
consonants+=1
print("Number of upper:",upper)
print("Number of lowercase:",lower)
print("Number of vowels:",vowel)
print("Number of consonants:",consonants)

OUTPUT:
The Content in vowels file is:
The Program will create the file name in your program's folder..

Number of upper: 2
Number of lowercase: 49
Number of vowels: 19
Number of consonants: 32
Q2. MySQL 4 Marks
Consider the following tables ‘Customer’ and ‘ Order’.
Table: Customer
CUSTOMERID CUSTOMERNAME CITY MOBILENO
C1 ABHISHEK AHMEDABAD 9999999999
C2 BHAVIK BARODA 8888888888
C3 CHANDABI AHMEDABAD 6666666666
C4 DHARA MUMBAI 55555555555
C5 DIVYA PATNA 7777777777
Table: Order
ORDERID ORDERDATE ORDERAMT CUSTOMERID
O1 2024-04-10 1500 C1
O2 2024-05-20 1800 C5
O3 2024-05-31 1000 C6
O4 2024-06-12 1400 C3

Write SQL commands for the following:


1. Display CustomerID, CustomerName and bill amount for customers belongs to
Ahmedabad.
SELECT CUSTOMERID,CUSTOMERNAME,ORDERAMT FROM
CUSTOMER,ORDER WHERE
CUSTOMER.CUSTOMERID=ORDER.CUSTOMERID AND
CITY=’AHMEDABAD’;
2. Display the order details in descending order of amount.
SELECT * FROM ORDER ORDER BY ORDERAMT DESC;
Write SQL output based on the given query:
3. SELECT ORDERID,ORDERDATE,CUSTOMERNAME,MOBILENO
FROM CUSTOMER,ORDER WHERE
CUSTOMER.CUSTOMERID=ORDER.CUSTOMERID;
ORDERID ORDERDATE CUSTOMERNAME MOBILENO
O1 2024-04-10 ABHISHEK 9999999999
O2 2024-05-20 DIVYA 7777777777
O4 2024-06-12 CHANDABI 6666666666

4. SELECT CUSTOMERID,CUSTOMERNAME,ORDERAMT FROM


CUSTOMER,ORDER WHERE
CUSTOMER.CUSTOMERID=ORDER.CUSTOMERID AND
ORDERAMT>=1500;
CUSTOMERID CUSTOMERNAME ORDERAMT
C1 ABHISHEK 1500
C5 DIVYA 1800
SET 5
Q1. PYTHON 8 Marks
Write a Python Program that has a list containing 10 integers. You need to help him
create a program with separate user defined functions to perform the following
operations based on this list.
Traverse the content of the list and push the ODD numbers into a stack. Pop and display
the content of the stack.

SOURCE CODE:
N=[12, 13, 34, 56, 21, 79, 98, 22,35, 38]
def PUSH(S,N):
S.append(N)
def POP(S):
if S!=[]:
return S.pop()
else:
return None
ST=[]
for k in N:
if k%2!=0:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else:
break

OUTPUT:
35 79 21 13
Q2. MySQL 4 Marks
Consider the tables ‘Books’ and ‘Issued’
Table : Books
BID BNAME AUNAME PRICE TYPE QTY
COMP11 LET US C YASHWANT 350 COMPUTER 15
GEOG33 INDIA MAP RANJEET P 150 GEOGRARHY 20
HIST66 HISTORY R BALA 210 HISTORY 25
COMP12 MY FIRST C VINOD DUA 330 COMPUTER 18
LITR88 MY DREAMS ARVIND AD 470 NOBEL 24

Table : Issued
BID QTY_ISSUED
HIST66 10
COMP11 5
LITR88 15

Write SQL commands for the following:


1. Display the book id, book name and quantity issued for all books which have
been issued.
SELECT BID,BNAME,QTY_ISSUED FROM BOOKS,ISSUED WHERE
BOOKS.BID=ISSUED.BID;
2. Display the book id, book name, author name, quantity issued for all books which
price are 200 to 400.
SELECT BID,BNAME,AUNAME,QTY_ISSUED FROM
BOOKS,ISSUED WHERE BOOKS.BID=ISSUED.BID AND PRICE
BETWEEN 200 AND 400;

Write SQL output based on the given query:


3. SELECT BNAME,PRICE,QTY FROM BOOKS WHERE QTY>20;
BNAME PRICE QTY
HISTORY 210 25
MY DREAMS 470 24

4. SELECT * FROM BOOKS NATURAL JOIN ISSUED;


BID BNAME AUNAME PRICE TYPE QTY QTY_ISSUED
COMP11 LET US C YASHWANT 350 COMPUTER 15 10
HIST66 HISTORY R BALA 210 HISTORY 25 5
MY
LITR88 ARVIND AD 470 NOBEL 24 15
DREAMS

You might also like