Buds Public School, Dubai

HOLIDAY ASSIGNMENT Class: 12- Science/Commerce Subject: Computer Science 1. Explain about Simple relational operators in DBMS with examples?

2. What is candidate key? Example?

3. The following WORKERS and DESIG. Write SQL commands for the statements (i) to (viii) and give outputs for SQL queries (ix)

(i) To display W_ID, FIRSTNAME, ADDRESS and CITY of all employees living in New York or Howard from the table WORKERS. (ii) To display the content of NewYork workers in descending order of W_ID. (iii) To display the FIRSTNAME, LASTNAME and total salary of all Manager from the tables WORKERS and DESIGN, where total salary is calculated as SALARY +BENEFITS. (iv) To display the minimum benefits and maximum salary among Managers and salesman from the table DESIG. (v) To display the content of workers whose Firstname start wit letter ‘R’ (vi)Give 500 increment in salary and 100 decrement in benefits for all the clerk (vii). Delete Paris record (viii) To display the content of design when the salary range is from 65000 to 90000 (ix) Give the output of following: a. SELECT FIRSTNAME, SALARY FROM WORKERS, DESIG WHERE DESIGNATION = ‘Director’ AND WORKERS.W_ID = DESIG.W_ID b. SELECT count (DISTINCT DESIGNATION ) FROM DESIG. c. SELECT DESIGNATION, SUM(BENIFITS) FROM DESIG GROUP BY DESIGNATION HAVING COUNT(*)>=3; d.SELECT SUM(SALARY) FROM DESIG WHERE DESIGNATION = ‘Salesman’ or W_ID IN(300,335,400);

4. find the output class color: red=350 green="leaf" def __init__(self,pink=10,rose=20): self.pink=pink+15 self.rose=rose+25 color.red*=2 def __str__(self): self.allcolor=str(self.pink)+"@"+str(self.rose)+"@"+color.green+"@"+str(color.red) return(self.allcolor) def getyellow(self,yellow=3): self.pink+=yellow self.rose-=yellow color.green="mango" color.red*=yellow def __del__(self): print "have a nice day" def main(): cat1=color(25,50) cat2=color(45) print "Now cat2……….. ", cat2 cat2.getyellow() cat3=color(2700) cat1.getyellow(30) print "Now cat1……….. ", cat1 del cat1 cat2.getyellow(1) del cat2 print cat3 del cat3 main() 5. find the output class employee: """ it is about employee details here for every obj creation eno will be increment automatically""" eno=0 dept="IT" def __init__(self,ename=' ',sal=7000): self.ename=ename self.sal=sal employee.eno+=1 self. getemployee() def getemployee(self,bonus=500): self.sal+=bonus if(self.sal>5000): print employee.eno,"#",self.ename,"#",self.sal,"#",employee.dept else: print employee.eno,"*",self.ename,"*", self.sal,"*",employee.dept def __del__(self): print "Good luck" class job(employee): def disp(self): print "Nice job" def main(): emp1=employee("charles",9000) emp2=employee("Raja",3000) print "line1.....",emp2.__dict__() print "line 2.", emp1.__class__.__name__() print "line3...", job.__bases__() print "line4...", employee.__bases__() print "line5...", employee.__doc__() print "line6...", job.__modules__() print "getattr....1....",getattr(emp2,ename) print "hasattr...... 2....", hasattr(emp1,eno) emp1.getemployee(2000) print "getattr....3....",getattr(emp1,sal) setattr(emp1,name,"chellam") delattr(emp2,ename) print "getattr....4....",getattr(emp1,ename) del emp1 print "hasattr...... 5....", hasattr(emp2,ename) print "hasattr...... 6....", hasattr(emp 1,sal) main() 6. Fill in the blanks: class sports: bat=250 #class var def __init__(self,ball, stemp): ------# assign stemp to its instance private var ------# assign ball in to its instance var ------# give 12 decrement for its class var ------# call getrun method @staticmethod def getsix (): ______# print all the var def getrun (self,stick): ____.bat+= stick _____.ball-= stick _____._ _stemp*=stick ______#print all the var ______# call getsix function ______# call _ _getfour function def _ _getfour(self,x,y): print (x+y) def __str__(self): self.jack="welcome" ______def __del__(self): print "hi" def main(): ______# create instance of the class ______# call getrun method ______# call getsix method ______# print bat var and ball var ______# call string method ______# destroy the instance Main()

7.Find the output: def popcorn(self): print "Welcome to all" print "-" * 50 class student: def __init__(self,rno=10,sname=" "): self.rno=rno self.sname=sname def getstudents(self): print self.rno,"#",self.sname def chocklate(self): for i inrange(0,10,1): print "*", def main(): ss=student(101,"Nicky") setattr(student,"icecream",popcorn) kk=student(102,"Amrith") ss.getstudents() kk.icecream() ss.kitkat=MethodType(chocklate,ss) ss.kitkat() main() 8. consider the following class definition: class colorful: def __init__(self,marks,name): self.marks=marks self.name=name def printdata(self): ----(method1) self.marks=50 self.name=”xyzw” print marks,”:”, print name @staticmethod: def givedata(): ------(method2) print “hi” (i) Give the statement to create object of class colorful (ii) Assuming xx is the object , what would be the output of xx.printdata() (iii) Identify the method1 (printdata) and method2(givedata) method types (iv) How to call method2 givedata function

9. Create a class TRAIN with following information: Train_no, Train_name, T_Cost, T_Type Methods: A constructor , to assign initial value of Train_no, T_Cost as 0 and Train_name,T_Type as null Inputdata()- to read the datamembers (Train_no, Train_name, & T_Type) and call find_traincost(). Find_traincost()- to find train cost(T_cost) by T_Type T_Type T_Cost First class 800 Second class 500 Third class 350 Showdata() – to display the details of entire class train 10. Create the class SOCIETY with following information: Data Members: society, house_no, no_of_members , income , and Flat Methods(functions):  Inputdata( ) - to read data members(society, house_no, no_of_members & income) and call allocate_flat().  allocate_flat( ) - To allocate flat according to income Income Flat >=25000 A Type >=20000 and <25000 B Type <15000 C Type  Showdata( ) - to display the details of the entire class.

11. Answer the following: class hospitol: def __init__(self,hno,hname): self.hno=hno self.__hname=hname hospitol.hphone=1003 def gethospitol(self): #...... def __puthospitol(self): #...... @StaticMethod def givehospitol(): #...... class patient(hospitol): def __init__(self,pno,pname): self.pno=float(pno) self.__pname=pname patient.pphone=”2345” def getpatient(self): #...... def __putpatient(self): #...... @StaticMethod def givepatient(): #...... class bill(patient): def __init__(self,billno,bdate): self.billno=billno self.__bdate=bdate patient.bamount=5432.75 def getbill(self): #...... def __putbill(self): #...... @StaticMethod def givebill(): #...... (a). Identify , which type of inheritance is this (b). Write the datamembers which are accessible by object of class bill (c) . Write the member function which are accessible from inside the class patient (d). Write the members which are accessible by object of class hospital (e). Write the datamembers which are accessible by from the class bill (f). Write the memberfunction which are accessible from the function getbill()

12. Demonstrate the following concept using Multilevel inheritance Define a class Stupersonal , with the following datamembers rno,sname,grade and member function getstudata()- to read the i/p. putstudata()- to print the o/p Define a class stumarks , with the following data members m1,m2 and member function getstumark()- to read the i/p. putstumark()- to print the o/p Define a class stugrade , with following datamembers tot,result and member function getresult()- to find tot and result. If all the marks >=40 result=pass , otherwise result-Fail . putresult()- to print the o/p

13. Find the output: aa=[10,20,30,40,50,60,70,80,90,100] product={“pcode”:101,”pname”:”xyz”,”price”:350} print aa[3],”;”,aa[2:7],”:”,aa[-7],”;”aa[-7:-2] print aa[2:10:3],”;”,aa[:7:2],”:”,aa[::2] print “list name………….”,product.get(“pname”) print “list keys………….”,product.keys() print “list items……………..”,product.items() print “list value……………”, product.values()

14. Rewrite the following code after removing all error(s). Underline the corrections done: class mango: def get(self) self.a=input(“enter the no) mango.b=input(“enter the name”)

@staticmethod def give(self) self.a=10 mango.b==”fruit” mm=mango(10) mm.get() mm.give() 15. Difference between Static Binding and Dynamic Binding 16. Explain Function Overloading with example 17. Explain Static Method with example 18. Write function definition, syntax of calling from inside the class, syntax of calling from outside the class for the following: * Constuctor Function * Destructor Function * String Function 19. Explain he following wit diagram:

* Multilevel Inheritance

* Hybrid Inheritance 20. Explain about Special relational operators in DBMS with examples?

21. What is Primary key? Example?

22. The following Employee and JOB Write SQL commands for the statements (i) to (viii) and give outputs for SQL queries (ix) Table: Employee

Table: JOB:

(i) To display W_ID, LASTNAME, ADDRESS and CITY of all employees living in Paris Howard from the table Employee. (ii) To display the content of Paris Employee in Alphebetical order of LasName. (iii) To display the FIRSTNAME, LASTNAME and Bonus of all Clerk from the tables WORKERS and DESIGN, where Bonus is calculated as (SALARY +BENEFITS)*25/100. (iv) To display the Number of Employees among Managers and salesman from the table DESIG. (v) Create table WORKERS using given above table (note: WID – Primary key) (vi)add the following values in to Employee table: (500,”ABC”,”XYZ”,”14 North side”,”Dubai”) (vii). Delete New York record (viii) To display the content of design when the Benefits range is from 12000 to 20000 (vii) Give the output of following: a. SELECT LASTNAME, BENIFITS FROM EMPLOYEE, JOB WHERE DESIGNATION = ‘Manager’ AND EMPLOYEE.W_ID = JOB.W_ID b. SELECT DISTINCT DESIGNATION FROM JOB. c. SELECT DESIGNATION, MAX(BENIFITS), MIN(SALARY) FROM JOB GROUP BY DESIGNATION HAVING COUNT(*)<3; d.SELECT SUM(SALARY) FROM JOB WHERE DESIGNATION = ‘Salesman’ AND W_ID IN(300,335,400);

23. find the output class color: red=3500 green="leaf" def __init__(self,pink=10,rose=20): self.pink=pink-15 self.rose=rose-25 color.red*=10 def __str__(self): self.allcolor=str(self.pink)+":"+str(self.rose)+":"+color.green+":"+str(color.red) return(self.allcolor) def getyellow(self,yellow=3): self.pink-=yellow self.rose+=yellow color.green="mango" color.red*=yellow def __del__(self): print "Getting Fast" def main(): cat1=color(3500,5000) cat2=color(4500) print "Now Obj2……….. ", cat2 cat2.getyellow() cat3=color(700) cat1.getyellow(300) print "Now obj1……….. ", cat1 del cat1 cat2.getyellow(1) del cat2 print cat3 del cat3 main() 5. find the output class employee: """ it is about Personal details of each employee Also ……………………………… here ename sal is instance var """ eno=100 dept="IT" def __init__(self,ename=' ',sal=7000): self.ename=ename self.sal=sal employee.eno+=10 self. getemployee() def getemployee(self,bonus=500): self.sal+=bonus if(self.sal>5000): print employee.eno,":",self.ename,"#",self.sal,":",employee.dept else: print employee.eno,"$",self.ename,"*", self.sal,"$",employee.dept def __del__(self): print "Good luck" class job(employee): def disp(self): print "Nice job" def main(): emp1=employee("Nikitha",12000) emp2=employee("Niyathi",2000) print "answer1.....",emp2.__dict__() print " answer 2.", emp1.__class__.__name__() print " answer3...", job.__bases__() print " answer4...", employee.__bases__() print " answer5...", employee.__doc__() print " answer6...", job.__modules__() print "Mothod getattr....1....",getattr(emp2,ename) print " Mothod hasattr...... 2....", hasattr(emp1,eno) emp1.getemployee(2000) print "getattr....3....",getattr(emp1,sal) setattr(emp1,name,"Bessi") delattr(emp2,ename) print " Mothod getattr....4....",getattr(emp1,ename) del emp1 print " Mothod hasattr...... 5....", hasattr(emp2,ename) print " Mothod hasattr...... 6....", hasattr(emp 1,sal) main() 6. Fill in the blanks: class sports: bat=4587 #class var def __init__(self,ball, stemp): ------# give 10 increment for its class var ------# assign stemp to its instance private var ------# assign ball in to its instance var ------# call getrun method def getrun (self,stick): ____.bat+= stick _____.ball-= stick _____._ _stemp*=stick ______#print all the var ______# call getsix function ______# call _ _getfour function def _ _getfour(self,x,y): print (x+y) @staticmethod def getsix (): ______# print all the var

def __str__(self): self.apple="Thank U" ______def __del__(self): print "hi" def main(): ______# create instance of the class ______# call getrun method ______# print bat var and ball var ______# call string method ______# call getsix method ______# destroy the instance Main() 7.Find the output: def popcorn(self): print "Popcorn is running" print "$" * 10 class student: def __init__(self,rno=10,sname=" "): self.rno, self.sname =rno,sname def getstudents(self): print self.rno,"#",self.sname def chocklate(self): for i in range(10,0,-2): print ":", def main(): s1=student(1001,"Nisanth") setattr(student,"icecream",popcorn) k1=student(1002,"Aakansh") s1.getstudents() k1.getstudents() k1.icecream() s1.kitkat=MethodType(chocklate,s1) s1.kitkat() main() 8. consider the following class definition: class Bright: def __init__(self,marks,name): self.marks=marks self.name=name def printdata(self): ----(method1) self.marks=50 self.name=”xyzw” print marks,”:”, print name @staticmethod: def givedata(): ------(method2) print “hi” (v) Give the statement to create object of class Bright (vi) Assuming yy is the object , what would be the output of yy.printdata() (vii) Identify the method1 (printdata) and method2(givedata) method types (viii) How to call method2 givedata function 9. Create the class SOCIETY with following information: Data Members: society, house_no, no_of_members , income , and Flat Methods(functions):  Constructor– to assign house_no and no_of_members as 0 and society as NULL  Inputdata( ) - to read data members(society, house_no, no_of_members & income) and call allocate_flat().  allocate_flat( ) - To allocate flat according to income Income Flat >=25000 A Type >=20000 and <25000 B Type <15000 C Type  Showdata( ) - to display the details of the entire class. 10. Create a class TRAIN with following information: Train_no, Train_name, T_Cost, T_Type Methods: Inputdata()- to read the datamembers (Train_no, Train_name, & T_Type) and call find_traincost(). Find_traincost()- to find train cost(T_cost) by T_Type T_Type T_Cost First class 800 Second class 500 Third class 350 Showdata() – to display the details of entire class train

11. Answer the following: class hospitol: def __init__(self,hno,hname): self.hno=hno self.__hname=hname hospitol.hphone=1003 def gethospitol(self): #...... def __puthospitol(self): #...... @StaticMethod def givehospitol(): #...... class patient(hospitol): def __init__(self,pno,pname): self.pno=float(pno) self.__pname=pname patient.pphone=”2345” def getpatient(self): #...... def __putpatient(self): #...... @StaticMethod def givepatient(): #...... class bill(hospitol): def __init__(self,billno,bdate): self.billno=billno self.__bdate=bdate patient.bamount=5432.75 def getbill(self): #...... def __putbill(self): #...... @StaticMethod def givebill(): #...... (a). Identify , which type of inheritance is this (b). Write the member function which are accessible from inside the class patient (c) . Write the datamembers which are accessible by object of class bill (d). Write the members which are accessible by object of class hospital (e). Write the memberfunction which are accessible from the function getbill() (f). Write the datamembers which are accessible by from the class bill

12. Demonstrate the following concept using Multiple inheritance Define a class Hospitol , with the following datamembers hno, hname,haddress and member function getthosp()- to read the i/p. puthosp()- to print the o/p Define a class Pharmacy , with the following data members medcode,medname,medqty,medprice and member function getpharmacy()- to read the i/p. putpharmacy()- to print the o/p Define a class Hoverall , with following datamembers medtotprice and member function getoverall()- to calculate medtotprice by multiply medprice and medqty . putoverall()- to print the o/p

13. Find the output: ` aa=[100,90,80,70,60,50,40,30,20,10] product={“pcode”:2001,”pname”:”Chocklate”,”price”:25} print aa[3],”;”,aa[2:7],”:”,aa[-7],”;”aa[-7:-2] print aa[2:10:3],”;”,aa[:7:2],”:”,aa[::2] print “Given name………….”,product.get(“pname”) print “Given keys………….”,product.keys() print “Given items……………..”,product.items() print “Given value……………”, product.values()

14. Rewrite the following code after removing all error(s). Underline the corrections done: class Apple: def get(self) self.a=input(“enter the no) mango.b=input(“enter the name”)

@staticmethod def give(self) self.a=10 mango.b==”fruit” mm= Apple (10) mm.get() mm.give() 15. Explain the concept of Operator Overloading with its built function name table 16. Explain Function Overriding with example 17. Explain String Function with example 18. Write the following, how to call from inside the class , & how to call from outside the class * Instance var * Instance Private var * Class var * Class Private var 19. Explain he following wit diagram:

* Single Inheritance

* Multiple Inheritance