100+ Important Most expected questions Computer Science Class 12

Most expected questions Computer Science

In this article, I am going to discuss important and most expected questions computer science class 12. Let us start the article with important questions and their solutions. Here we go!

Most expected questions computer science class 12

I am going to discuss questions that are most probably asked in the CBSE board exam. Here we are going to start with questions about the topic of data structure in python. Mostly you will get 2 marks and 3 marks for questions on this topic.

Let us see the most expected questions computer science class 12 asked for 1, 2 and 3 marks questions.

Data Structure Stack questions

The first topic we are going to cover is Data Structure Stack. Here we go!

1 mark objective types questions data structure stack class 12 computer science

[1] Kunj wants to remove an element from empty stack. Which of the following term is related to this?

a) Empty Stack

b) Overflow

c) Underflow

d) Clear Stack

[2] ____________ is an effective and reliable way to represent, store, organize and manage data in systematic way.

[3] Which of the following is elementary representation of data in computers?

a) Information

b) Data

c) Data Structure

d) Abstract Data

[4] ____________ represents single unit of certain type.

a) Data item

b) Data Structure

c) Raw Data

d) None of these

[5] Statement A: Data Type defines a set of values alog with well-defined operations starting its input-output behavior

Statement B: Data Structure is a physical implementation that clearly defines a way of storing, accessing, manipulating data.

a) Only Statement A is True

b) Only Statement B is True

c) Both are True

d) Both are False

[6] Which of the following python built in type is mostly suitable to implement stack?

a) dictionary

b) set

c) tuple

d) list

[7] The Data Structures can be classified into which of the following two types?

a) Stack and Queue

b) List and Dictionary

c) Simple and Compund Data Structure

d) Easy and Comoplex Data Structure

[8] Identify Data Structure from the given facts:

  1. I am single level data strcuture.
  2. My elements are formed from a sequence.

a) Linear Data Structure

b) Non-Linear Data Structure

c) Dynamic Data Structure

d) Static Data Structure

[9] Which of the following is an example of non-linear data structure?

a) Stack

b) Queue

c) Linked List

d) Tree

[10] Which of the following is/are an example(s) of python ‘s built-in linear data structure?

a) List

b) Tuple

c) Set

d) All of these

[11] _____________ is a linear data structure implemented in LIFO manner where insertion and deletion are restricted to one end only.

a) Stack

b) Queue

c) Tree

d) Linked List

[12] Which of the following is an example of stack?

a) Students standing in Assembly

b) People standing railway ticket window

c) Chairs arranged in a vertical pile

d) Cars standing on the road on traffic signal

[13] Which of the following operation of stack is performed while inserting an element into the stack?

a) push

b) pop

c) peep

d) Overflow

[14] Which of the folloiwng operation is considered as deletion of element from stack?

a) push

b) pop

c) underflow

d) overflow

[15] Which of the following pointer is very essential in stack operations?

a) front

b) top

c) middle

d) bottom

[16] The fixed length data structure is known as _____________

a) dynamic data stcuture

b) fixed length data structure

c) static data stucture

d) intact data structure

[17] __________ refers to insepecting an element of stack without removing it.

a) push

b) pop

c) peek

d) underflow

[18] Consider the following data:

[11,20,45,67,23]

The following operations performed on these:

push(19)

pop()

push(24)

pus(42)

pop()

push(3)

What will be the contents of the list evelntually?

a) [11,20,45,67,23]

b) [3,24,11,20,67,23]

c) [42,24,11,20,67,23]

d) [24,11,20,67,23]

[19] The LIFO structure can be also same as ______________

a) FILO

b) FIFO

c) FOFI

d) LOFI

[20] Consider the folloiwing data structure implemented a list as stack:

11

22

23

34

91

Which of the following is function is executed thrice to get this result:

34

91

a) delete()

b) pop()

c) remove()

d) clear()

Most expected 2 marks Most expected questions Stack Computer Science Class 12

[1] What is Stack? Write any one application of Stack?

[2] List out any two real-life examples of Stack.

[3] Define stack. What is the significance of TOP in stack?

[4] Give any two characteristics of stacks.

[5] What do you mean by push and pop operations on stack?

[6] What is LIFO data structure? Give any two applications of a stack?

[7] Name any two linear Data Structures? What do you understand by the term LIFO?

[8] Name four basic operations performed on stack.

[9] Why stack is called LIFO data structure?

[10] What do you mean by underflow in the context of stack?

[11] Consider STACK=[23,45,67,89,51]. Write the STACK content after each operations:

  1. STACK.pop( )
  2. STACK.append(99)
  3. STACK.append(87)
  4. STACK.pop( )

[12] Differentiate between list and stack.

[13] Differentiate between push and pop in stacks.

[14] Write an algorithm for pop operation in stack.

[15] Write an algorithm for push operation in stack.

Watch this video for more understanding:

If you are looking for notes on stack data structure, click on this link:

Data Structure Stack Class 12

Follow this link for more questions:

QnA Data Structure Class 12

Most expected 3 marks Stack Programming questions computer science

  1. Write a function push (student) and pop (student) to add a new student name and remove a student name from a list student, considering them to act as PUSH and POP operations of stack Data Structure in Python.

Ans.:

def push(student):
    name=input("Enter student name:")
    student.append(name)

def pop(student):
   if student==[]:
        print("Underflow")
   else:
        student.pop()

2. Write PUSH(Names) and POP(Names) methods in python to add Names and Remove names considering them to act as Push and Pop operations of Stack.

def PUSH(Names):
   name=input("Enter name:")
   Names.append(name)

def POP(Names):
    if Names==[]:
      print("Underflow")
    else:
       Names.pop()

3. Ram has created a dictionary containing names and age as key value pairs of 5 students. Write a program, with separate user defined functions to perform the following operations:

Push the keys (name of the student) of the dictionary into a stack, where the corresponding value(age) is lesser than 40. Pop and display the content of the stack.

For example:  If the sample content of the dictionary is as follows:

R={“OM”:35,”JAI”:40,”BOB”:53,”ALI”:66,”ANU”:19}  

The output from the program should be:

ANU OM

R={"OM":35,"JAI":40,"BOB":53,"ALI":66,"ANU":19}

def Push(stk,n):
   stk.append(n)

def Pop(stk):
   if stk!=[]:
     return stk.pop()
   else:
     return None
s=[]
for i in R:
   if R[i]<40:
      Push(s,i)

while True:
    if s!=[]:
       print(Pop(s),end=" ")
    else:
       break

4. SHEELA has a list containing 5 integers. You need to help Her create a program with separate user defined functions to perform the following operations based on this list.

  1. Traverse the content of the list and push the odd numbers into a stack.
  2. Pop and display the content of the stack.

For Example:

If the sample Content of the list is as follows:

N=[79,98,22,35,38]

Sample Output of the code should be:

35,79

N=[79,98,22,35,38]

def Push(stk,on):
   stk.append(on)

def Pop(stk):
   if stk==[]:
     return None
   else:
     return stk.pop()
stk=[]

for i in N:
   if i%2!=0:
      Push(stk,i)

while True: 
    if stk!=[]:
      print(Pop(stk),end=" ")
    else:
      break

5. Write a function in Python PUSH_IN(L), where L is a list of numbers. From this list, push all even numbers into a stack which is implemented by using another list.

N=[79,98,22,35,38]

def Push(stk,on):
   stk.append(on)

def Pop(stk):
   if stk==[]:
     return None
   else:
     return stk.pop()
stk=[]

for i in N:
   if i%2==0:
      Push(stk,i)

while True: 
    if stk!=[]:
      print(Pop(stk),end=" ")
    else:
      break

6. Write a function in Python POP_OUT(Stk), where Stk is a stack implemented by a list of numbers. The function returns the value which is deleted/popped from the stack.

def POP_OUT(Stk):
   if Stk==[]:
      return None
   else:
      return Stk.pop()

7. Julie has created a dictionary containing names and marks as key value pairs of 6 students. Write a program, with separate user defined functions to perform the following operations:

  1. Push the keys (name of the student) of the dictionary into a stack, where the corresponding value (marks) is greater than 75.
  2. Pop and display the content of the stack.

For example:

If the sample content of the dictionary is as follows:

R={“OM”:76, “JAI”:45, “BOB”:89, “ALI”:65, “ANU”:90, “TOM”:82}

The output from the program should be: TOM ANU BOB OM

R={"OM":76, "JAI":45, "BOB":89, "ALI":65, "ANU":90, "TOM":82}
def Push(stk,n):
   stk.append(n)

def Pop(stk):
   if stk!=[]:
     return stk.pop()
   else:
     return None
s=[]
for i in R:
   if R[i]>75:
      Push(s,i)

while True:
    if s!=[]:
       print(Pop(s),end=" ")
    else:
       break

8. Raju has created a dictionary containing employee names and their salaries as key value pairs of 6 employees. Write a program, with separate user defined functions to perform the following operations:

  1. Push the keys (employee name) of the dictionary into a stack, where the corresponding value (salary) is less than 85000.
  2. Pop and display the content of the stack.

For example:

If the sample content of the dictionary is as follows:

Emp={“Ajay”:76000, “Jyothi”:150000, “David”:89000, “Remya”:65000, “Karthika”:90000, “Vijay”:82000}

The output from the program should be:

Vijay Remya Ajay

Emp={"Ajay":76000, "Jyothi":150000, "David":89000, "Remya":65000, "Karthika":90000, "Vijay":82000}

def Push(stk,sal):
    stk.append(sal)

def Pop(stk):
  if stk==[]:
    return None
  else:
    return stk.pop()

stk=[]

for i in Emp:
   if Emp[i]<85000:
     Push(stk,i)

while True:
  if stk!=[]:
    print(Pop(),end=" ")
  else:
    break 

9. Anjali has a list containing temperatures of 10 cities. You need to help her create a program with separate user-defined functions to perform the following operations based on this list.

  1. Traverse the content of the list and push the negative temperatures into a stack.
  2. Pop and display the content of the stack.

For Example:  

If the sample Content of the list is as follows:

T=[-9, 3, 31, -6, 12, 19, -2, 15, -5, 38]

Sample Output of the code should be: -5 -2 -6 -9

T= [-9, 3, 31, -6, 12, 19, -2, 15, -5, 38]

def Push(s,n):
  s.append(n)

def Pop(s):
  if s!=[]:
   return s.pop()
  else:
   return None


s=[]
for i in T:
   if i<0:
     Push(s,i)

while True:
  if s!=[]:
   print(Pop(s),end = " ")
  else:
   break

10. Ms.Suman has a list of integers. Help her to create separate user defined functions to perform following operations on the list.

  1. DoPush(elt) to insert only prime numbers onto the stack.
  2. DoPop() to pop and display content of the stack.

For eg:if L=[2.5,6,11,18,24,32,37,42,47] then stack content will be 2 5 11 37 47

def DoPush(elt):
 L= [2,5,6,11,18,24,32,37,42,47]
 for i in L:
  for j in range(2,i):
    if i % j ==0:
     break
  else:
    elt.append(i)


def DoPop(s):
  if s!=[]:
     return s.pop()
  else:
     return None

s=[]
DoPush(s)

while True:
  if s!=[]:
    print(DoPop(s),end=" ")
  else:
    break

11. Mr. Ramesh has created a dictionary containing Student IDs and Marks as key value pairs of students. Write a program to perform the following operations Using separate user defined functions.

  1. Push the keys (IDs) of the dictionary into the stack, if the corresponding marks is >50
  2. Pop and display the content of the stack

For eg:if D={2000:58,2001:45,2002:55,2003:40} Then output will be: 2000,2002

Do Yourself…

12. Write AddNew (Book) and Remove(Book) methods in Python to add a new Book and Remove a Book from a List of Books Considering them to act as PUSH and POP operations of the data structure Stack?

def AddNew(Book):
   name=input("Enter Name of Book:")
   Book.append(name)

def Remove(Book):
   if Book==[]:
    print("Underflow")
   else:
    Book.pop()

13. Assume a dictionary names RO having Regional Offices and Number of nodal centre schools as key-value pairs. Write a program with separate user-defined functions to perform the following operations:

  1. Push the keys (Name of Region Office) of the dictionary into a stack, where the corresponding value (Number of Nodal Centre Schools) is more than 100.
  2. Pop and display the content of the stack.

For example

If the sample content of the dictionary is as follows:

RO={“AJMER”:185, “Panchkula”:95, “Delhi”:207, “Guwahati”:87, “Bubaneshwar”:189}

The output from the program should be:

AJMER    DELHI  BHUBANESHWAR

Do yourself…

14. Write a function in Python PUSH (Lst), where Lst is a list of numbers. From this list push all numbers not divisible by 7 into a stack implemented by using a list. Display the stack if it has at least one element, otherwise display appropriate error message.

def PUSH(Lst):
  stk=[]
  for i in range(len(Lst)):
    if Lst[i]%7==0:
      stk.append(Lst[i])

  if len(stk)==0:
    print("Stack is underflow")
  else:
    print(stk)

15. Write a function in Python POP(Lst), where Lst is a stack implemented by a list of numbers. The function returns the value deleted from the stack.

def POP(Lst):
   if len(stk)==0:
    return None
   else:
    return Lst.pop()

16. Reva has created a dictionary containing Product names and prices as key value pairs of 4 products. Write a user defined function for the following:

PRODPUSH()  which takes a list as stack and the above dictionary as the parameters. Push the keys (Pname of the product) of the dictionary into a stack, where the corresponding price of the products is less than 6000. Also write the statement to call the above function. 

For example: If Reva has created the dictionary is as follows: 

Product={“TV”:10000, “MOBILE”:4500, “PC”:12500, “FURNITURE”:5500}

The output from the program should be: [ ‘FURNITURE’, ‘MOBILE’]

Do Yourself…

17. Pankaj has to create a record of books containing BookNo, BookName and BookPrice. Write a user- defined function to create a stack and perform the following operations:   

  1. Input the Book No, BookName and BookPrice from the user and Push into the stack.
  2. Display the status of stack after each insertion.
def Push():
   books=[]
   stk=[]
   bno=int(input("Enter Book Number:"))
   bname=input("Enter Book Name:")
   bprice=input("Enter Book Price:")
   books=[bno,bname,bprice]
   stk.append(books)
   print(stk)   

18. Write a function in Python PUSH(mydict),where mydict is a dictionary of phonebook(name and mobile numbers), from this dictionary push only phone numbers having last digit is greater than or equal to 5 to a stack implemented by using list. Write function POP() to pop and DISPLAY() to display the contents.

if it has at least one element, otherwise display “stack empty” message.

>>> mydict={9446789123:”Ram”,8889912345:”Sam”,7789012367:”Sree”}

>>> push(mydict)

Phone number: 9446789123 last digit is less than five which can’t be pushed

Stack elements after push operation : [7789012367, 8889912345]

mydict={9446789123:"Ram",8889912345:"Sam",7789012367:"Sree"}

def Push(mydict):
    stk=[]
    for i in mydict:
        if i%10>=5:
            stk.append(i)
    print(stk)

Push(mydict)

19. Write a function to push an element in a stack which adds the name of passengers on a train, which starts with capital ‘S’. Display the list of passengers using stack.

For example: L = [‘Satish’,’Manish’,’Sagar’,’Vipul’]

Output will be: Satish Sagar

L = ['Satish','Manish','Sagar','Vipul']
def Push(L,name):
    L.append(name)
stk=[]

for i in L:
    if i[0]=='S':
        Push(stk,i)

print(stk)

20. In a school a sports club maintains a list of its activities. When a new activity is added details are entered in a dictionary and a list implemented as a stack. Write a push() and pop() function that adds and removes the record of activity. Ask user to entre details like Activity, Type of activity, no. of players required and charges for the same.

Do Yourself…

Watch this video for practical understanding.

In the next section of Most expected questions Computer Science, I am going to discuss questions from unit 2 computer networks.

Most expected questions Unit II Computer Networks Computer Science Class 12

So let us discuss the most expected questions from Unit II Computer Networks for Computer Science Class 12. From this unit 1, 2, 3, 4, and 5 marks are going to be asked in your board exams. So here we go!

1 mark Unit 2 Computer Networks most expected questions computer science class 12

  1. ……………………………. is a network of physical objects embedded with electronics, software, sensors and network connectivity.
  2. ……………….. is a device that forwards data packets along networks.
  3. ———————- describes the maximum data transfer rate of a network or Internet connection.
  4. It is an internet service for sending written messages electronically from one computer to another. Write the service name.
  5. As a citizen of india , What advise you should give to others for e-waste disposal?
  6. Name the protocol that is used to send emails.
  7. Your friend Ranjana complaints that somebody has created a fake profile on Facebook and defaming her character with abusive comments and pictures. Identify the type of cybercrime for these situations.
  8. Name The transmission media best suitable for connecting to hilly areas.
  9. Write the expanded form of Wi-Fi.
  10. Rearrange the following terms in increasing order of data transfer rates. Gbps, Mbps, Tbps, Kbps, bps
  11.   ______is a communication methodology designed to deliver both voice and multimedia communications over Internet protocol. 
  12. Out of the following, which is the fastest wired and wireless medium of transmission? Infrared, coaxial cable, optical fibre, microwave, Ethernet cable

Answers:

  1. IoT
  2. router
  3. Network bandwidth
  4. Email
  5. People can take e-waste to recycling centres
  6. SMTP
  7. Cyber Stalking
  8. Radiowave or Microwave
  9. Wireless Fidelity
  10. bps -> Kbps -> Mbps -> Gbps -> Tbps
  11. VoIP
  12. Wired – Optical Fibre, Wireless – Microwave

Most expected 2 mark questions Unit 2 Computer networks

[1] Mr. Pradeep is working as a network admin in Durga Pvt. Ltd. He needs to connect 40 stand-alone computers in one unit using a server. How it is beneficial for the company? List out any two points.

[2] Differentiate between LAN, MAN, WAN.

[3] Dhara wants to connect her telephone network with the internet. Suggest a device she should use for the same and write any two functions of the device.

[4] What is an IP address? Write one example of IP Address.

[5] Bharti wants to know the term used for the process of converting a domain name into IP address. How it works?

[6] Illustrate the layout for connecting 5 computers in a Bus and a Star topology of Networks.

bus-topology-class-12-computer-science
bus-topology-class-12-computer-science
start-topology-computer-science-class-12-imp-questions
start-topology-computer-science-class-12-imp-questions

[7]

(a) Santosh wants a client/server protocol, in which e-mail is received and held by him on his computer from an Internet server. Regularly, it should check his mailbox on the email server and download mails to his computer. Which protocol out of the following will be ideal for the same?

(i) POP3

(ii) SMTP

(iii) VoIP

(iv) HTTP

(b) Riya is in India and she is interested in communicating with her friend in Canada. She wants to show one of her paintings to him and also wants to explain how it was prepared without physically going to Canada. Which protocol out of the following will be ideal for the same?

(i) POP3          

(ii) SMTP               

(iii) VoIP                

(iv) HTTP

[8]

(a) Ketan is working as a team leader in Resonance LTD. Company. He wants to host an online meeting for all the branches of India and present an annual report. Which technology is best suited for such a task?

(b) Mahi is accessing remote computers and data over TCP/IP networks. Which protocol is used to do this?

[9] Write short note on packet switching, message switching and circuit switching.

[10] Out of the following wired and wireless mediums of communication, which is the fastest:

Infrared, Coaxial Cable, Ethernet Cable, Microwave, Optical Fiber

[11] Vidya College has three departments that are to be connected into a network.

(a) Which of the following communication medium out of the given options should be used by the college for connecting their departments for very effective high-speed communication?

  1. Coaxial cable
  2. Optical Fibre
  3. Ethernet Cable

(b) Also name the type of network out of (LAN/WAN/MAN) formed between various departments of the college.

[12]

(a) Which network device regenerates the signal over the same network before the signal becomes too weak or corrupted .

(b) Which network device connects two different networks together that work upon different networking models so that two networks can communicate properly.

[13]

(a) Which of the following is/are not communication media?

(i) Microwaves

(ii) Optical Fiber cable

(iii) Node

(iv) Radio waves

(b) Which of the following is/are not a topology?

(i) Star

(ii) Bus

(iii) Ring

(iv) Ethernet

[14] Identify the following media out of guided and unguided media?

Ethernet, Infrared, Bluetooth, Fibre Optic, Coaxial, Satellite, Radiowave, Microwave

[15] Name the devices :

  1. This device links two networks together and is not a broadcast device, as it filters traffic depending upon the receiver’s MAC address.
  2. This device offers a dedicated bandwidth.

[16] Expand TCP/IP. Write the purpose of TCP/IP in the communication of data on a network.

[17] Write the expanded names for the following abbreviated terms used in Networking:

(i) MBPS                            

(ii) WAN                            

(iii) CDMA                                        

(iv) WLL

[18] Give two advantages and two disadvantages of tree topology.

[19] Define the following terms: website , web browser

[20] Expand the following: ARPANET, NSFNet

[21] Identify the transmission medium used in the following:

  1. TV Remotes
  2. Cellular Networks

[22] Define: Web Server, Web Hosting

[23] Differentiate between IP address and MAC address.

[24] (i) Name the connector used to connect ethernet cable to computer and hub or switch.

(ii) Name the cables used in TV networks.

[25] (i) Name a network topology, which is used to maximize speed and make each computer
independent of the network.
(ii) Suggest a switching technique in which the information is transferred using Store and
Forward mechanism.

[26] Write two advantages of using an optical Fiber cable over a Twisted Pair cable to connect two service stations which are 200m away from each other.

[27] What is the difference between hub and switch? Which is preferable in a large network of computers and why?

[28] Give two advantages and two disadvantages of Bus topology.

[29] Prakash wishes to install a wireless network in his office. Explain him the differences between guided and unguided media.

[30] Which media is best for the following:

(i) Hilly Area

(ii) Large Industries

(iii) Point to point communication between two individuals

(iv) 4G

Most expected 4 Marks questions Unit II Computer Networks Computer Science Class 12

Watch this video for 4 marks questions from Unit II Computer networks class 12 Computer Science.

Most expected questions Unit III Database Management Computer Science Class 12

In the next section of Most expected questions Computer Science Class 12 we are going to cover questions from Unit III Database Management System Computer Science Class 12. From this unit 2, 3 and 4 marks will be asked. Here we go!

Most expected 2/3 marks questions Unit III Database Management Computer Science Class 12

[1] What is MySQL? List some popular versions of MySQL.

[2] Hetal is inserting “Rathod” in the “LastName” column of the “Emp” table but an error is being displayed. Write the correct SQL statement.

INSERT INTO Emp(‘Rathod’)VALUES(LastName) ;

[3] Darsh created the following table with the name ‘Friends’ :

Table : Friends

Freind_CodeNameHobbies
F001AnuragTravelling
F002ManishWatching Movies

Now, Darsh wants to delete the ‘Hobbies’ column. Write the MySQL statement.

[4] Mr. Nikunj entered the following SQL statement to display all Salespersons of the cities “Chennai” and ‘Mumbai’ from the table ‘Sales’.

Table: Sales

ScodeNameCity
S0001Krishanan IyerChennai
S0002Atmaram BhideMumbai
S0003Jethalal GadaBhachau
S0004Venugopal SrinavasanaChennai
S0005Mandar MumbaikarMumbai

SELECT * FROM Sales WHERE City=‘Chennai’ AND City=‘Mumbai’;

He is getting the Empty Set as output. Explain the problem with the statement and rewrite the correct statement.

[5] Is NULL value the same as 0 (zero) ? Write the reason for your answer.

[6] Write the UPDATE command to increase the commission (Column name : COMM) by 500 of all the Salesmen who have achieved Sales (Column name : SALES) more than 200000. The table’s name is COMPANY.

[7] While using SQL pattern matching, what is the difference between ‘_’ (underscore) and ‘%’ wildcard symbols?

[8] What is the meaning of open source and open source database management system?

[9] In a table employee, a  column occupation contains many duplicate values. Which keyword would you use if wish to list of only different values? Support your answer with example.

[10] How is alter table statement different from UPDATE statement?

[11] Charvi wants to delete the records where the first name is Rama in the emp table. She has entered the following SQL statement. An error is being displayed. Rewrite the correct statement.

Delete from firstname from emp;

[12] What is the relationship between SQL and MySQL?

[13] Rani wants to add another column ‘Hobbies’ with datatype and size as VARCHAR(50) in the already existing table ‘Student’. She has written the following statement. However, it has errors. Rewrite the correct statement.

MODIFY TABLE Student Hobbies VARCHAR;

[14] Write SQL query to display employee details from table named ‘Employee’ whose ‘firstname’ ends with ‘n’ and firstname contains a total of 4 characters (including n).

[15] Identify aggregat functions of MySQL amongst the following :

TRIM(), MAX(), COUNT(*), ROUND()

[16] Write the following statement using ‘OR’ logical operator :

SELECT first_name, last_name, subject FROM studentdetails WHERE subject IN (‘Maths’, ‘Science’);

[17] What is MySQL used for? Ajay wants to start learning MySQL. From where can he obtain the MySQL software?

[18] In the table ‘‘Student’’, Priya wanted to increase the Marks (Column Name:Marks) of those students by 5 who have got Marks below 33. She has entered the following statement :

SELECT Marks+5 FROM Student WHERE Marks <33;

Rewrite the correct statement.

[19] Consider a table Accounts and answer the following:

(i) Name the Data type that should be used to store AccountCodes like ‘‘A1001’’ of Customers.

(ii) Name two Data types that require data to be enclosed in quotes.

[20] Given the table ‘Player’ with the following columns :

Table – Player

PcodePoints
P00195
P00282
P00374
P00493
P00577

Write the output of the following queries:

  1. SELECT AVG(POINTS) FROM Player;
  2. Select COUNT(POINTS) FROM Player;

Watch this video for more understanding:

[21] Differentiate between char and varchar. Priya has created a table and used char(10) and varchar(10) as a datatype for two of the columns of her table. What (10) indicate here?

[22] ‘Employee’ table has a column named ‘CITY’ that stores city in which each employee resides. Write SQL query to display details of all rows except those rows that have CITY as ‘DELHI’ or ‘MUMBAI’ or ‘CHANDIGARH’.

[23] Ajay has applied a Constraint on a column (field) such that

(i) Ajay will certainly have to insert a value in this field when he inserts a new row in the table.

(ii) If a column is left blank then it will accept 0 by itself.

Which constraints has Ajay used?

[24] ‘STUDENT’ table has a column named ‘REMARK’ that stores Remarks. The values stored in REMARK column in different rows are “PASS” or “NOT PASS” or “COMPTT” etc. Write SQL query to display details of all rows except those that have REMARK as “PASS”.

[25] Consider the table : Company

SIDSales
S001250
S002100
S002200

What output will be displayed by the following SQL statements?

(i) select avg(sales) from company where sales>200;

(ii) select sum(sales)/2 from company where SID=’S002′;

[26] Consider the table ‘Hotel’ given below:

Table : Hotel

EMPIDCategorySalary
1001Permanent25000
1002Contract18000
1003Adhoc10000
1004Contract12000
1005Permanent20000

Mr. Vinay wanted to display the average salary of each Category. He entered the following SQL statement. Identify error(s) and Rewrite the correct SQL statement.

SELECT Category, Salary FROM Hotel GROUP BY Category;

Write one more query to display maximum salary category wise.

[27] Namrata has created the following table with the name ‘Order’.

FieldConstraint
OrderIDPrimary Key
OrderDateNot Null
OrderAmount
StoreID

Answer the following:

  1. What is the data type of columns OrderId and OrderDate in the table Order?
  2. Namrata is now trying to insert the following row : O102, NULL, 59000, S105

[28] Write SQL query to create a table ‘Event’ with the following structure :

FieldData TypeSizeConstraint
eventidvarchar5Primary Key
eventvarchar30not null
locationvarchar50Ahmedabad should be by default
clientidintegerForeign Key
Parent table (Client)
eventdatedate

[29] How is a Primary key constraint different from a Unique key constraint?

[30] Write two similarities between CHAR and VARCHAR data types.

[31] Consider “TravelPackage” table with “source” column. Entering data for the Location column is optional. If one enters data for a row with no value for the “source” column, what value will be saved in the “source” column? Write SQL statement to display the details of rows in the “travelpackage” table whose location is left blank.

[32] Define: Field/Attribute, Tuple/Record

[33] Define: Degree and Cardinality

[34] Define: Candidate Key, Alternate Key

[35] A NULL value can be inserted into a foreign key? Justify your answer.

[36] Ravindra is confused about what is a domain? Clear his confusion with an example.

[37] Consider the following table – Student

AdmNoRollNoNameClassMarks
10011ShaileshX76
10022KamalaaXII89
10033DineshXI85

Identify the candidate keys and alternate keys.

[38] Enlist any four popular RBMDS software.

[39] A table “clustergames” exists with 4 columns and 6 rows. What is its degree and cardinality, initially? 2 rows are added to the table and 1 column deleted. What will be the degree and cardinality now?

[40] Sejal wants to create a table patient. Help her to do the following:

(i) She is confused about how the dates are stored in MySQL? Suggest the date format.

(ii) She want to display all records from the table and she wrote the following command:

show * from patient;

She is not getting the output. Rewrite the correct statement.

[41] What is sorting? Which keyword is used to sort data from the table in SQL?

[42] Rajni wants to apply sorting on a table through SQL. But he is not aware about how to use order by clause. Explain the order by clause in short to him with example.

Most expected 4 marks questions computer science class 12 Unit 3 Database Management

[1] Consider the following tables participant and activity and answer the questions :

Table – Participant

ADMNONAMEHOUSEACTIVITYOCDE
A001Sagar PatelRedAC001
A002Kaushik MahetaBlueAC002
A003Noor JoshiGreenAC003
A004Mahesh JoshiYellowAC004
A005Nutan ChauhanBlueAC001
A006Mahek PatelYellowAC004
A007Sidhdharth PatelBlueAC003
A008Gaurang VyasGreenAC004

Table – activity fields: activitycode, activityname, points

ACTIVITYCODEACTIVITYNAMEPOINTS
AC001Poem Recitation120
AC002Maths Quiz150
AC003Science Quiz180
AC004Sports200
  1. When the table ‘‘PARTICIPANT’’ was first created, the column ‘NAME’ was planned as the Primary key by the Programmer. Later a field ADMNO had to be set up as Primary key. Explain the reason.
  2. Identify data type and size to be used for column ACTIVITYCODE in table ACTIVITY.
  3. Write a query to display Activity Code along with the number of participants participating in each activity (Activity Code wise) from the table Participant.
  4. How many rows will be there in the Cartesian product of the two tables in consideration here?
  5. To display Names of Participants, Activity Code, and Activity Name in alphabetic ascending order of names of participants.
  6. To display Names of Participants along with Activity Codes and Activity Names for only those participants who are taking part in Activities that have ‘quiz’ in their Activity Names and Points of activity are above 150.

[2] Consider the following tables SUPPLIER and ITEM and answer the questions

Table – Supplier

SNOSNAMEAREAEMAIL
1A to Z SuppliersNarola2zsupp@gmail.com
2Rathi Brothers Company Pvt. Ltd.Narodarathibrothers@gmail.com
3Rushan CommunicationsDanilimdarushan786@gmail.com
4Apex Entreprise Pvt. Ltd.Maninagarapexmaninagar@gmail.com
5Mahi Transport Co. Ltd.Maninagarmahimaninagar@gmail.com
6Dhareja TravelsNarodadharejatravelsnaroda@gmail.com
7Sameer SuppliersNarolsameersuppliers@gmail.com

Table – Item

INOINAMEPRICESNO
I001Cargo 280001
I002Cartoon5002
I003LG Mobiles26003
I004Truck on Rent550001
I005Reliance SIM7003
I006Packing Material80001
I007Moterbikes700004
  1. Which column should be set as the Primary key for SUPPLIER table ?
  2. Mr. Vijay, the Database Manager feels that Email column will not be the right choice for Primary key. State reason(s) why Email will not be the right choice.
  3. Write the data type and size of INo column of ‘ITEM’ table.
  4. To display names of Items, SNo and Names of Suppliers supplying those items for those suppliers who have stores located in Naroda.
  5. To display Names of Items, SNo, Price and Corresponding names of their suppliers of all the items in ascending order of their Price.
  6. To display Item Name wise, Minimum and Maximum Price of each item from the table item. i.e. display IName, minimum price and maximum price for each IName.)
  7. What will be the number of rows in the Cartesian product of the above two tables?

[3] Consider the table given below:

Table – Faculty

TEACHERIDNAMEADDRESSSTATEPHONENUMBER
T001AvinashAhmedabadGujarat9825741256
T002AkhileshJaipurRajasthan9824456321
T003ShivanshMumbaiMaharashtra9327045896
T004MinaxiNew DelhiDelhi9012547863

Table – Course, Fields: coruseid, subject, teacherid, fee

COURSEIDSUBJECTTEACHERIDFEE
1001Computer ScienceT0016750
1002Informatics PracticesT0044550
  1. Which column is used to relate the two tables?
  2. Is it possible to have a primary key and a foreign key both in one table? Justify your answer with the help of table given above.
  3. With reference to the above given tables, write commands in SQL for (i) and (ii) and output for (iii) :
    • (i) To display CourseId, TeacherId, Name of Teacher, Phone Number of Teachers living in Delhi.
    • (ii) To display TeacherID, Names of Teachers, Subjects of all teachers with names of Teachers starting with ‘S’.
    • (iii) SELECT CourseId, Subject,TeacherId,Name,PhoneNumber FROM Faculty,Course WHERE Faculty.TeacherId = Course.TeacherId AND Fee>=5000;

[4] Write commands in SQL for (1) to (4) and output for (5) and (6).

Table : Store

STOREIDNAMELOCATIONCITYNOOFEMPLOYEESDATEOPENEDSALESAMOUNT
S01BHAGYA LAXMISATELLITEAHMEDABAD72018-04-0125000
S02PARTH FASHIONAKOTABARODA22010-07-1545000
S03KRISHNA SAREESUMARWADASURAT82020-08-1385000
S04SAMEER CLOTHESRELIEF ROADAHMEDABAD22012-06-0278000
  1. To display name, location, city, SalesAmount of stores in descending order of SalesAmount.
  2. To display names of stores along with SalesAmount of those stores that have ‘fashion’ anywhere in their store names.
  3. To display Stores names, Location and Date Opened of stores that were opened before 1st March, 2015.
  4. To display total SalesAmount of each city along with city name.
  5. SELECT distinct city FROM store;

[7] Consider the following DEPT and EMPLOYEE tables. Write SQL queries for (1) to (4) and find outputs for SQL queries (5) to (8).

Table:DEPT

DCODEDEPARTMENTLOCATION
10AGRICULTUREANAND
20MINESNADIAD
30TPPKHEDA
40MECHANICALAHMEDABAD

Table:EMP

ENONAMEDOJDOBGENDERDCODE
1111MISKA2020/03/011997/11/15F10
1112AKSHAY2018/06/051998/12/04M20
1113NEEL2021/07/012000/10/20M10
1114ANKITA2016/04/252001/10/27F30
1115MOHIT2016/12/222003/11/02M40
  1. To display Eno, Name, Gender from the table EMPLOYEE in ascending order of Eno.
  2. To display the Name of all the MALE employees from the table EMPLOYEE.
  3. To display the Eno and Name of those employees from the table EMPLOYEE who are born between ‘1997-01-01’ and ‘1999-12-01’.
  4. To count and display FEMALE employees who have joined after ‘1999-01-01’.
  5. SELECT COUNT(*),DCODE FROM EMPLOYEE GROUP BY DCODE HAVING COUNT(*)>1;
  6. SELECT DISTINCT DEPARTMENT FROM DEPT;
  7. SELECT NAME,DEPARTMENT FROM EMPLOYEE E,DEPT D WHERE E.DCODE=D.DCODE AND ENO<1113
  8. SELECT MAX(DOJ), MIN(DOB) FROM EMPLOYEE;

Watch the following video for more understanding:

Most expected Questions 2/3 marks interface of python with MySQL

[1] Nisha is trying to create a project on python. Where she wants to store the records in a database. She learnt about front-end and back-end, But forget what it means right now. Help her by giving definition of front-end and backend.

[2] What is DB-API?

[3] What does DB-API include?

[4] Man wants to install the mysql connector. Suggest steps to install the same.

[5] Prakash has installed mysql connector. Now he wants to check whether its properly installed or not. Suggest python command to do this task.

[6] Name any two python mysql connector modules.

[7] What are the main components of mysql.connector module?

[8] What do you mean by a connection?

[9] What do you mean by cursor object?

[10] What are the parameters of mysql.connector.connect method?

[11] Neel is trying to write the connect method. Help him by filling the given gaps:

import ____________ as ms
cn=ms.________(host=localhost,user='root',passwd='root',database='school') 
cr=cn._____()
cn.______()

[12] Fill the proper words in the following code snippet:

cn=mysql.connector.connect(_______=localhost,________='root',________='root',______='school') 

[13] Babita wants to insert a record into the table using a python MySQL connector. Suggest two methods which are used to execute the query using the cursor object.

[14] What are the methods used to read data from SQL tables?

[15] Differentiate between fetchone() and fetchmany().

[16] Is rowcount method? Explain in short.

[17] Consider the following table: IPL2022

RankBatterRunsTeam
1Jos Buttler863RR
2KL Rahul616LSG
3Quinton de Kock508LSG
4Hardik Pandya487GT
5Shubman Gill483GT

Observe the following given code and write the output:

import mysql.connector as ms
cn=ms.connect(host='localhost',user='root',passwd='root',database='IPL')
cr=cn.cursor()
cr.execute("seleect * from IPL2022")
r=cr.fetchone()
r=cr.fetchone()
r=cr.fetchone()
data=int(r[2])
print(data*2)

[18] Consider the table given in the above question and write the for this code snippet:

import mysql.connector as ms
cn=ms.connect(host='localhost',user='root',passwd='root',database='IPL')
cr=cn.cursor()
cr.execute("seleect * from IPL2022")
r=cr.fetchone()
print("No. of records fetched:",cr.rowcount)
r=cr.fetchmany(2)
print("No. of records fetched:",cr.rowcount)

[19] Consider the tabe given in question no. 17 and write python code to display the top 3 run-scorer.

[20] Consider the table given in question 17 and write python code to display details for those batsmen who score less than 500 runs.

[21] Write python code to insert this record: (6,’David Miller’,481,’GT’)

[22] Write python code to update short team name GT to full team name Gujarat Titans.

[23] Write code to delete record of David Miller.

Watch this video for practical understanding:

Follow this link to access term sample papers:

Computer Science Class 12 Sample Paper

Thats’ all from Most expected questions Computer Science Class 12. I hope this article will help you to prepare well for your board exam. Thank you for visit:

Feel free to give your feedback in the following feedback form and help us to improve: