Document 4

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

S.

NO PROGRAM SIGN
21 Write a function in python named POP(STACK) where STACK is
a stack implemented by a list of numbers. The function will
display the popped element after function call.
22 Write a function AddCustomer(Customer) in Python to add a
new Customer information NAME into the List of CStack and
display the information.
23 Write a function DeleteCustomer() to delete a Customer
information from a list of CStack. The function delete the name
of customer from the stack.
24 Write the SQL statement to create EMPLOYEE relation which
contains EMPNO, Name, Skill, PayRate.
25 Create a table with the under mentioned structure (Table
name is DEPT) DeptNo NUMBER(2)
DeptName CHAR(12)
Location CHAR(12)
26 Create a table called SALGRADE with the columns specified
below:
LowSal NUMBER(7,2)
HighSal NUMBER(7,2)
Grade NUMBER(2)
27 Create a table called PROJECT with the columns specified
below
ProjId NUMBER(4)
ProjDesig CHAR(20)
ProjStartDT DATE
ProjEndDT DATE
BudgetAmount NUMBER(7)
MaxNoStaff NUMBER(2)
28 Insert a record with suitable data in the table EMP, having
system date as the Hiredate
29 WAP To create database (MySQL connectivity)
30 WAP To show database (MySQL connectivity
31 WAP To update record in Table Student (MySQL connectivity)
32 WAP To describe structure of table student (MySQL
connectivity)
Q21.Write a function in python named POP(STACK) where STACK is a stack
implemented by a list of numbers. The function will display the popped element
after function call
def POP(STACK):

if STACK==[]:
def PUSH(STACK,SET):
for i in SET:
if i%2==0:
STACK.append(i)

print(STACK)

Q22. Write a function AddCustomer(Customer) in Python to add a new Customer


information NAME into the List of CStack and display the information
CStack=[]
def AddCustomer(Customer):
CStack.append(Customer)
if len(CStack)==0:
print (“Empty Stack”)
else:
print (CStack)
Q23. Write a function DeleteCustomer() to delete a Customer information from a
list of CStack. The function delete the name of customer from the stack.
CStack=[]
def DeleteCustomer():
if (CStack ==[]):
print(“There is no Customer!”)
else:
print(“Record deleted:”,CStack.pop())

Q24.Write the SQL statement to create EMPLOYEE relation which contains


EMPNO, Name, Skill, PayRate
CREATE TABLE Employee ( EmpNo CHAR(4) NOT NULL PRIMARY KEY, Name
CHAR(20) NOT NULL, Skill CHAR(1), PayRate DECIMAL(8,2));

Q25.Create a table with the under mentioned structure (Table name is DEPT)
DeptNo NUMBER(2)
DeptName CHAR(12)
Location CHAR(12)
CREATE TABLE Dept ( DeptNo NUMBER(2) NOT NULL PRIMARY KEY, DeptName
CHAR(12), Location CHAR(12);
Q26.Create a table called SALGRADE with the columns specified below:
LowSal NUMBER(7,2)
HighSal NUMBER(7,2)
Grade NUMBER(2)
CREATE TABLE Salgrade (LowSal Decimal(7,2), HighSal DECIMAL(7,2), Grade
NUMBER(2) );

Q27.Create a table called PROJECT with the columns specified below


ProjId NUMBER(4)
ProjDesig CHAR(20)
ProjStartDT DATE
ProjEndDT DATE
BudgetAmount NUMBER(7)
MaxNoStaff NUMBER(2)
CREATE TABLE Project ( ProjId Number(4) NOT NULL PRIMARY KEY, ProjDesig
Char (20) NOT NULL, ProjStartDT Date, ProjEndDT DATE, BudgetAmount
Decimal(7,2) default=0, MaxNoStaff Number(2) );

Q28.Insert a record with suitable data in the table EMP, having system date as the
Hiredate
INSERT INTO Emp VALUES (3008, 18, “XAVIER”, “Manager”, Date( ), 3250, NULL);

Q29.WAP To create database (MySQL connectivity)


import mysql.connector
mydb=mysql.connector.connect(host=”localhost”,user=”root”,passwd=”12345″)
mycursor=mydb.cursor()
mycursor.execute(“CREATE DATABASE SCHOOL”)
Q30.WAP To show database (MySQL connectivity
import mysql.connector
mydb=mysql.connector.connect(host=”localhost”,user=”root”,passwd=”12345″)
mycursor=mydb.cursor()
mycursor.execute(“SHOW DATABASE”)
for x in mycursor:
print (x)

Q31.WAP To update record in Table Student (MySQL connectivity)


import mysql.connector
mydb=mysql.connector.connect(host=”localhost”,user=”root”,passwd=”12345″,da
tabase=”student”)
mycursor=mydb.cursor()
mycursor.execute(“UPDATE STUDENT SET MARKS=100 WHERE MARKS=40″)
mydb.commit()
print(mycursor.rowcount,”RECORD UPDATED”)

Q32.WAP To describe structure of table student (MySQL connectivity)


import mysql.connector
mydb=mysql.connector.connect(host=”localhost”,user=”root”,passwd=”12345″,da
tabase=”student”)
mycursor=mydb.cursor()
mycursor.execute(“DESC STUDENT”)
for x in mycursor:
print(x)

You might also like