Computer Science - Informatics Practices Class XI/XII MySQL Test Series Part 12

Computer Science - Informatics Practices Class XI/XII MySQL Test Series Part 12


Q1. Write the output of the following on the basis of given table : Product

  


1. Select max(price) from product;

2. Select avg(price) from product;

3. Select min(qty) from product;

4. Select count(*) from product;

5. Select count(Qty) from product;

6. Select distinct(price) from product;

7. Select count(distinct(price)) from product;

8. Select price * Qty from product;

9. Select sum(price) from product;

10. Select sum(price) where Qty > 30;


 SOLUTIONS

Q1. Write the output of the following on the basis of given table : Product

  


1. Select max(price) from product;

Ans. 320

2. Select avg(price) from product;

Ans. 218

3. Select min(qty) from product;

Ans. 17

4. Select count(*) from product;

Ans. 5

5. Select count(Qty) from product;

Ans. 5

6. Select distinct(price) from product;

Ans. 

240

300

320

130

100

7. Select count(distinct(price)) from product;

Ans. 5

8. Select price * Qty from product;

Ans. 

5520

7200

13760

4160

1700

9. Select sum(price) from product;

Ans. 1090

10. Select sum(price) where Qty > 30;

Ans. Error



Data Structure Test 4

 Data Structure Test 4

Q1. A linear stack called "List" contain the following information:
            a. Roll Number of student
            b. Name of student
Write add(List) and pop(List) methods in python to add and remove from the stack.

Ans. 

List=[]
def add(List):
rno=int(input("Enter roll number"))
name=input("Enter name")
item=[rno,name]
List.append(item)
def pop(List):
if len(List)>0:
List.pop()
else:
print("Stack is empty")
#Call add and pop function to verify the code
add(List)
add(List)
pop(List)
print(List)

Q2. Write push(edetail) and pop(edetail) in python to add and remove the employee detail in a stack called "edetail".

"edetail" stack store the following details:

       a. Name of employee

       b. Salary of employee

Ans.

edetail = []
def push(edetail):
name = input("Enter name")
sal = int(input("Enter Salary"))
item = [name, sal]
edetail.append(item)
def pop(edetail):
if len(edetail) > 0:
edetail.pop()
else:
print("Stack is empty")

#Call push and pop function to verify the code
push(edetail)
push(edetail)
pop(edetail)
print(edetail)

Q3. Write addscore(game) and delscore(game) methods in python to add and remove score from a list "game", considering these methods to act as push and pop operations of data structure stack.

Ans.

game = []
def addscore(game):
sc=int(input("Enter Score"))
game.append(sc)
def pop(ed):#in place of 'ed' we can use 'game'also
if len(ed) > 0:
ed.pop()
else:
print("Stack is empty")
#Call functions to verify the code
addscore(game)
addscore(game)
pop(game)
print(game)

OR (When we don't want to accept value from
the user)

game = []
def addscore(sc):
game.append(sc)
def pop():
if len(game) > 0:
game.pop()
else:
print("Stack is empty")
#Call functions to verify the code
addscore(23)
addscore(54)
pop()
print(game)

Q4. Write addsal(sal) and removesal(sal) functions in python to add and remove salary from a list of salary in a list "sal", considering these methods to act as push and pop operations of data structure stack.

Ans.

sal = []
def addsal(sc):
sal.append(sc)
def pop():
if len(sal) > 0:
sal.pop()
else:
print("Stack is empty")
#Call functions to verify the code
addsal(23)
addsal(54)
pop()
print(sal)

Q5. Write addfee() function in python to add the following detail in list named "fee".
        feeamount
        feemonth
Considering this as push function of stack
Ans.
fee=[]
def addfee(fee):
fa=int(input("Enter the fee amount"))
fm = input("Enter the fee month")
item = [fa,fm]
fee.append(item)
addfee(fee)

Data Structure Test 5

 Data Structure Test 5

Q1. Write queueadd(clientname) and queuedel(clientname) methods in python to add a new client and delete a client from a list of Client Names, considering them to act as an insert and delete operations of the queue data structure.

Ans.

cn=[]
def queueadd(cn):
cname=input("Enter Client Name")
cn.append(cname)
def queuedel(cn):
if(len(cn)==0):
print("Queue is Empty")
else:
print("Deleted element is", cn[0])
del cn[0]
#you can call the following functions to verify
the above code
queueadd(cn)
queueadd(cn)
queueadd(cn)
queuedel(cn)
print(cn)

Q2. Write queueadd(pid) and queuedel(pid) methods in python to add a new product  and delete a product  from a list of product id, considering them to act as an insert and delete operations of the queue data structure. (Consider product id of integer type)
Ans.
pid=[]
def queueadd(cn):
prid=int(input("Enter Product id"))
cn.append(prid)
def queuedel(pid):
if(len(pid)==0):
print("Queue is Empty")
else:
print("Deleted element is", pid[0])
del pid[0]
#you can call the following functions to verify
the above code
queueadd(pid)
queueadd(pid)
queueadd(pid)
queuedel(pid)
print(pid)


Q3. Write add(book) and del1(book) methods in python to add a new book and delete a book  from a list of book name, considering them to act as an insert and delete operations of the queue data structure. 
Ans. 
book=[]
def add(book):
bn=input("Enter book name")
book.append(bn)
def del1(book):
if(len(book)==0):
print("Queue is Empty")
else:
print("Deleted element is", book[0])
del book[0]
#you can call the following functions to verify
#the above code
add(book)
add(book)
add(book)
del1(book)
print(book)

Q4. Write addq(Employee) and delq(Employee) methods in python to add a new Employee Name  and delete an Employee  from a list of Employee name, considering them to act as an insert and delete operations of the queue data structure. 
Ans. 
emp=[]
def addq(emp):
en=input("Enter employee name")
emp.append(en)
def delq(emp):
if(len(emp)==0):
print("Queue is Empty")
else:
print("Deleted element is", emp[0])
del emp[0]
#you can call the following functions to verify
#the above code
addq(emp)
addq(emp)
addq(emp)
delq(emp)
print(emp)

Q5. Write adding(Rollno) and deleting(Rollno) methods in python to add a new Roll Number and delete Roll Number  from a list of Roll Number, considering them to act as an insert and delete operations of the queue data structure. (Roll number is of type integer
Ans. 

rno=[]
def adding(rno):
rn=int(input("Enter Roll Number"))
rno.append(rn)
def deleting(rno):
if(len(rno)==0):
print("Queue is Empty")
else:
print("Deleted element is", rno[0])
del rno[0]
#you can call the following functions to verify
#the above code
adding(rno)
adding(rno)
adding(rno)
deleting(rno)
print(rno)

Data Structure Test 3


Data Structure Test 3

Q1. Write a function Push() which takes number as 
    argument and add in a  stack "MyValue"

Q2. Write a function Push that takes "name" as 
    argument and add in a stack named "MyStack"
 
Q3. Write a function Push() which takes "name" as
    argument and add in a stack named "MyStack".
    After calling push() three times, a message
    should be displayed "Stack is Full"

Q4. Write a function pop() which remove name
    from stack named "MyStack".
 
Q5. Write push(rollno) and pop() method in python:
    push(rollno) --add roll number in Stack
    pop() --- remove roll number from Stack.
 
 
Q6. Write add(bookname) and delete() method in  
    python to add bookname and remove bookname 
    considering them to act as push() and pop() 
    operations in stack.
 
Q7. Write addclient(clientname) and remove()
    methods in python to add new client and delete
    existing client from a list "clientdetail",
    considering them to act as push and pop
    operations of the stack.

 
SOLUTIONS

Q1. Write a function Push() which takes number as argument and add in a  stack "MyValue"
Ans. 
MyValue=[]
def Push(value):
  MyValue.append(value)

Q2. Write a function Push that takes "name" as argument and add in a stack named
"MyStack"
Mynames=[]
def Push(Value):
    Mynames.append(Value)
Push("Amit")
 
Q3. Write a function Push() which takes "name" as
argument and add in a stack named "MyStack".
After calling push() three times, a message
should be displayed "Stack is Full"
Ans.
MyStack=[]
StackSize=3
def Push(Value):
   if len(MyStack) < StackSize:
       MyStack.append(Value)
   else:
       print("Stack is full!")
 
Q4. Write a function pop() which remove name
from stack named "MyStack".
Ans.
def Pop(MyStack):
 if len(MyStack) > 0:
  MyStack.pop()
 else:
  print("Stack is empty.")
 
Q5. Write push(rollno) and pop() method in python:
    push(rollno) --add roll number in Stack
    pop() --- remove roll number from Stack.
 
Ans. 
MyStack=[]
def Push(rollno):
    MyStack.append(rollno)
def Pop(MyStack):
 if len(MyStack) > 0:
  MyStack.pop()
 else:
  print("Stack is empty.")
 
Q6. Write add(bookname) and delete() method in python
 to add bookname and remove bookname considering
them to act as push() and pop() operations in stack.
Ans.
MyStack=[]
def add(bname):
    MyStack.append(bname)
def delete(MyStack):
 if len(MyStack) > 0:
  MyStack.pop()
 else:
  print("Stack is empty. There is no book name")
 
Q7. Write addclient(clientname) and remove()
methods in python to add new client and delete
existing client from a list "clientdetail",
considering them to act as push and pop
operations of the stack.

Ans. 
clientdetail=[]
def addclient(cn):
   clientdetail.append(cn)

def remove():
   if len(clientdetail)>0:
      clientdetail.pop()
   else:
      print("Stack is empty")

   
 
 
 
 
 
 

 
 
 

Data Structure Test 2

 Data Structure Test 2
Q1. Organization of data means ______.
Q2. Write the full form of the following:
a. LIFO
b. FIFO
Q3. Which data structure is represented as FIFO?
Q4. Insertion into stack is called ______ (push/pop)
Q5. Giving printing command to printer is an example of _____ 
    (stack/queue)
Q6. Reversing a number or a word/string is an example of 
    ______(stack or queue)
Q7. In stack addition or removal of elements takes place at ___ 
    (one/both) end of the list.
Q8. In queue, addition of elements take place at one end and 
    removal of elements takes place at other end. (T/F)
Q9. If the elements "A", "B", "C" are added in the queue in the 
    following order,
    first A then B and in last C.
    In what order, it will come out of 
    queue?
Q10. _________ function is used to add an  element in stack.


SOLUTIONS

Ans 1. Data Structure

Ans 2. 
    a. Last In First Out
    b. First In First Out

Ans 3. Queue

Ans 4. Push

Ans 5. Queue

Ans 6. Stack

Ans 7. One

Ans 8. True

Ans 9. A, B, C

Ans 10. Append


Computer Science - Informatics Practices Class XI/XII MySQL Test Series Part 11

Computer Science - Informatics Practices Class XI/XII MySQL Test Series Part 11

Q1. What is the degree and cardinalty of table who has 6 columns and 10 rows?

Q2. Identify the errors in the following query

a. Select * from Student where Name = NULL;

b. Select max(salary) from employee group by designation where DOJ > "2020-02-02";

c. Select * from student where name is = "Amit";

d. Select * from employee where salary between 1000, 2000;

e. Select * from employee where name = "A%";

f. Select Name , Subject from student where average >20 and < 30;

g. Select * from Student where Name = "Amit" and Name ="Sumit";

h. Select highest(Salary) from employee;

i. Select all from student;

j. Update table student set Name = "Sunita" where admno = 1234;


SOLUTIONS

Q1. What is the degree and cardinalty of table who has 6 columns and 10 rows?

Ans. Degree - 6 and Cardinality - 10

Q2. Identify the errors in the following query

a. Select * from Student where Name = NULL;

Ans. Select * from Student where Name is NULL;

b. Select max(salary) from employee group by designation where DOJ > "2020-02-02";

Ans. Select max(salary) from employee group by designation having DOJ > "2020-02-02";

c. Select * from student where name is = "Amit";

Ans. Select * from student where name  = "Amit";

d. Select * from employee where salary between 1000, 2000;

Ans. Select * from employee where salary between 1000 and 2000;

e. Select * from employee where name = "A%";

Ans. Select * from employee where name  like "A%";

f. Select Name , Subject from student where average >20 and < 30;

Ans. Select Name , Subject from student where average >20 and average < 30;

g. Select * from Student where Name = "Amit" and Name ="Sumit";

Ans. Select * from Student where Name = "Amit" or Name = "Sumit";

h. Select highest(Salary) from employee;

Ans. Select max(Salary) from employee;

i. Select all from student;

Ans. Select * from Student;

j. Update table student set Name = "Sunita" where admno = 1234;

Ans. Update student set Name = "Sunita" where admno = 1234;


Computer Science - Informatics Practices Class XI/XII MySQL Test Series Part 10

Computer Science - Informatics Practices Class XI/XII MySQL Test Series Part 10

Q1. What is the difference between drop and delete command?

Q2. Differentiate between Alter and Update command.

Q3. What is group by clause?

Q4. Write the output of the following:

  1. Select 75 + 3*2 
  2. Select 23 + 56%5
  3. Select power(2,3)
  4. Select round(10.237,2)
  5. Select round(12.3454,2)
  6. Select round(12.3444,2)
Q5. Write the query on the basis of the following table :STUDENT 
Name, Admno, Subject, Average, Position
  1. Display all records in ascending order by name
      
      2. Display details of students whose position is "First" and average greater than 70
 
      
     3. Display details of "Amit", "Sumit" and "Ashish" (using IN operator)

     
    4. Display Name and Subject  of student whose position is "First"

    
   5. Display the total number of records present in above table.

   6. Display the maximum average.
 
   7. Display name of student who got maximum average.

   8. Insert he following record:
      "Shikha", 1221, "Physics", 70, "Second"

 


SOLUTIONS

Q1. What is the difference between drop and delete command?

Ans. Drop command delete the data as well as structure of table permanently from database

        while delete command delete only the data from the table.

Q2. Differentiate between Alter and Update command.

Ans. Alter command is used to change the structure of table and Update command is used 

       to modify the data of table.

Q3. What is group by clause?

Ans. This clause is used to arrange same data in groups using some group functions 

        like Sum, average etc.

Q4. Write the output of the following:

  1. Select 75 + 3*2 ------------------------------------Ans. 81
  2. Select 23 + 56%5----------------------------------Ans. 24
  3. Select power(2,3)----------------------------------Ans. 8
  4. Select round(10.237,2)----------------------------Ans. 10.24
  5. Select round(12.3454,2)---------------------------Ans. 12.35
  6. Select round(12.3444,2)---------------------------Ans. 12.34
Q5. Write the query on the basis of the following table :STUDENT 
Name, Admno, Subject, Average, Position
  1. Display all records in ascending order by name
      Ans. Select * from Student order by Name;

      2. Display details of students whose position is "First" and average greater than 70
 
      Ans. Select * from student where position ="First" and Average >70;

     3. Display details of "Amit", "Sumit" and "Ashish" (using IN operator)

     Ans. Select * from Student where Name IN("Amit", "Sumit", "Ashish");

    4. Display Name and Subject  of student whose position is "First"

    Ans. Select Name, Subject from student where position = "First";

   5. Display the total number of records present in above table.

   Ans. Select count(*) from Student.

   6. Display the maximum average.
 
   Ans. Select max(Average) from Student;

  7. Display name of student who got maximum average.

   Ans. Select Name, max(Average) from Student;

  8. Insert he following record:
      "Shikha", 1221, "Physics", 70, "Second"

  Ans. Insert into student values ("Shikha", 1221, "Physics", 70, "Second");

Most Recently Published

File Handling Test 6

 File Handling Test 6 Q1 . Do we need to use the close() function when we use 'with' statement to open a file? Q2. Which mode you wi...

CS - IP Assignment/Worksheet