Cs Worksheet
Cs Worksheet
a. if a = b : b. if a == b : c. if a === b d. if a == b
5 The ____________ statement prematurely ends the execution of the current while / for loop. 1
a. break b. continue c. pass d. None of these
9 Which of the following is correct with respect to Python Code given below? 1
Coins={"Five":10,"Ten":100}
a. one dictionary named Coins is created.
b. "Five" and "Ten" are the keys of dictionary named Coins
c. 10 and 100 are the values of dictionary named Coins
d. All of these
10 Consider the code below and choose the correct output from the given options: 1
customer = {"city": "Prayagraj", "State": "Uttar Pradesh", "capital": "Lucknow"}
print([Link]())
a. dict_items([{'city', 'Prayagraj'), ('State', 'Uttar Pradesh'), ('capital', 'Lucknow'}])
b. dict_items([('city', 'Prayagraj'), ('State', 'Uttar Pradesh'), ('capital', 'Lucknow')])
c. dict_items((['city', 'Prayagraj'], ['State', 'Uttar Pradesh'], ['capital', 'Lucknow']))
d. None of the Above
11 S = "Python Programming" 1
The output of statement print(S[::-1][::2]) is______________.
12 Which of the following methods will convert "PYTHON" to "python"? 1
a. lower("PYTHON") b. "PYTHON".tolower()
c. "PYTHON".lower() d. "PYTHON".lowerto()
25 Assertion (A) : In python, implicit type conversion automatically converts a lower data type to a 1
higher data type during expression evaluation
Reason (R) : Python allows conversion from float to int automatically if both are used in an
expression.
26 Assertion (A) : Keywords can not be used as normal identifiers. 1
Reason (R) : Keywords are reserved for special purposes.
27 Assertion (A) : In an if-else statement, the if block checks the true part whereas else checks for 1
the false part.
Reasoning (R) : In a conditional construct, the else block is mandatory.
28 Assertion (A) : In an if-else statement, the if block checks the true part whereas else checks for 1
the false part.
Reasoning (R) : In a conditional construct, the else block is mandatory.
34 Assertion (A) : Dictionaries are mutable but their keys are immutable. 1
Reason (R) : The values of a dictionary can change but keys of the dictionary cannot be
changed because through them data is hashed.
36 Assertion (A) : "Hello World".split() returns a list with one element:"Hello World" 1
Reason (R) : The split() method breaks a string into parts using the specified separator.
39 Observe the following code carefully and rewrite it after removing all syntactical errors. 2
Underline all the corrections made.
def 1func():
a=input("Enter a number"))
if a>=33
print("Promoted to next class")
ELSE:
print("Repeat")
40 Amit, a Python programmer, is working on a project in which he wants to write a function to 2
count the number of even and odd values in the list. He has written the following code but his
code is having errors. Rewrite the correct code and underline the corrections made.
define EOCOUNT(L):
even_no = odd_no = 0
for i in range(0,len(L))
if L[i]%2=0:
even_no+=1
else:
odd_no+=1
print(even_no, odd_no)
41 Rewrite the following code in python after removing all syntax error(s). Underline each 2
correction done in the code.
250 = Num
while Num <= 1000:
if Num => 750:
print Num
Num = Num + 100
else
print Num*3
Num= Num+ 150
42 Rewrite the following code in python after removing all syntax error(s). Underline each 2
correction done in the code.
while x>0
if a%2=0
print(a%2)
elseif a%3=0 then
print(a%3)
43 Rewrite the following code in python after removing all syntax error(s). Underline each 3
correction done in the code.
fruits = ['apple', 'banana' 'cherry']
t = (1, 2, 3)
t[1] = 100
k = (5,)
Print(k[0])
print(t)
print(fruits)
44 Rewrite the following code in python after removing all syntax error(s). Underline each 3
correction done in the code.
colors =list ["red", "green", "blue",]
[Link]["green"]
my_tuple = (10, 20, 30
tuple1 = (1, 2)
tuple2 = (3, 4)
result = tuple1 + tuple2[]
print(my_tuple)
print(colors)
45 The following python code contains an error. Rewrite the correct code and underline the 2
corrections made by you.
details= {"city": ["Prayagraj", "Patna"], "State": "Uttar Pradesh", "Bihar"]}
46 The following python code contains error(s). Rewrite the correct code and underline the 2
corrections made by you.
info = {"country": "India", "State": "Kerala", "Language":"Malayalam"}
print(values().info)
47 The following python code is trying to print all vowel characters in a given string. Rewrite the 2
correct code and underline the corrections made by you.
sub1="computer science"
sub2=""
for i in range(sub1):
if i ='aeiou':
sub2=sub2+str(i)
print(sub2)
s1 = 'Python world"
s1[8] = 'W'
print(upper(s1))
print(isupper(s1))
57 Consider the code below and choose the correct output from the given options: 1
customer = {"cname": "Shiv Prasoon", "country": "India", "mobile": "9956789876"}
print(customer['cname'], " :: ", [Link]('mobile'))
a. Shiv Prasoon 9956789876 b. Shiv Prasoon :: 9956789888
c. Shiv Prasoon :: 9956789876 d. Error
58 Consider the code below and choose the correct output from the given options: 1
customer = {"city": "Prayagraj", "State": "Uttar Pradesh", "capital": "Lucknow"}
print(len(customer))
a. 3 b. 6 c. 7 d. None of the Above
Python Functions
MULTIPLE CHOICE BASED QUESTIONS
1 Which one of the following is an incorrect way of importing the randint() function from the 1
random module?
a. import random b. from random import randint
c. import [Link] d. from random import *
2 The function which is defined by programmer and not available already in program is : 1
a. Library Function b. Customised Function
c. User Defined function d. Predefined Function
4 Which of the following function calls is incorrect if the function is defined as: 1
def calculate(a, b=2, c=3):
return a + b + c
a. calculate(1) b. calculate(1, 4) c. calculate(1, c=4) d. calculate(b=3, 1, c=2)
14 Assertion (A) : Importing a module with * makes the size of the program bigger. 1
Reason (R) : Python interpreter imports the module function code in the program before
execution.
15 Assertion (A) : In a Python function call, you can mix positional and keyword arguments. 1
Reason (R) : Python allows keyword arguments to be passed before positional arguments.
16 Assertion (A) : Default arguments in a function must be placed after all non-default 1
arguments.
Reason (R) : Python uses left-to-right evaluation for function arguments.
19 Rewrite the following code in python after removing all syntax error(s). Underline each 2
correction done in the code.
DEF calculate_sum(numbers)
sum = 0
for number in numbers:
sum = number
return Sum
print(call calculate_sum([1, 2, 3, 4, 5]))
20 Rewrite the following code in python after removing all syntax error(s). Underline each 2
correction done in the code.
def greet(name)
message = "Hello, " + name
return message
def farewell(name):
return "Goodbye " + name
print(greet(123)
print(farewell(456)
greet("John"
23 The following python code contains error(s). Rewrite the correct code and underline the 2
corrections made by you
def fun(a, b=3, c) :
Return a + b + c
x = fun (10, 20)
print(x)
24 The following python code contains error(s). Rewrite the correct code and underline the 2
corrections made by you
DEF test ( ) :
x=x+1
return x
print(x)
test ( )
import csv
with open('[Link]', 'r') as f:
reader = [Link](f)
next(reader)
for row in reader:
if int(row[3]) > 80:
print(row[1],end=’,’)
f = open("[Link]","r")
r = [Link](f)
for x in r:
print(x[0]+x[1])
a. 33 b. 55 c. error d. 1122
5. Ms. Priyanka is trying to find out the output of the following code. Help her to find the 1
correct output of the code:
with open("[Link]", "w") as f:
[Link](["Line1\n", "Line2\n", "Line3\n"])
with open("[Link]") as f:
print([Link]())
a. AB b. CD c. DE d. EF
7. What will be the output of following code? 1
a. Python b. Python
Rocks
c. Python\nRocks d. ['Python', 'Rocks']
8. What will be the output of the code below? 1
with open("[Link]", "w") as f:
[Link]("12345")
9. Which of the following statement opens a binary file [Link] in write mode and writes 1
data from a list
lst1 = [1,2,3,4]
a. file_object.seek(offset [, reference_point])
b. seek(offset [, reference_point])
c. seek(offset, file_object)
d. seek.file_object(offset)
Following questions are Assertion (A) and Reason (R) based questions. Mark
the correct choice as:
a. Both A and R are true, and R is the correct explanation of A
b. Both A and R are true, but R is not the correct explanation of A
c. A is true, but R is false
d. A is false, but R is true
14. Assertion (A): While writing data into a CSV file using [Link](), each
row must be passed as a list or tuple.
Reason (R): The writerow() method of [Link] class takes a single string
as input and writes it directly to the CSV file.
15. Assertion (A): The [Link] object in Python returns each row of a CSV file as a
list.
Reason (R): Each row read by [Link] can be accessed using a for loop.
16. Assertion (A): In Python, a binary file must be opened using mode "rb" and "wb"
for reading and writing respectively.
Reason (R): Binary files store data as text, which is compatible with standard
input/output functions like print().
17. Assertion (A): Opening a file in 'a' mode raises an error if the file does not
exist.
Reason (R): The 'a' mode also allows appending to existing files.
18. Assertion (A): [Link](0) can be used to re-read a file from the beginning.
Reason (R): seek() moves the file pointer to a specified location.
19. Assertion (A): Binary files store all data in text format.
Reasoning (R): Binary files data remain in its original type.
20. Assertion (A): Using the 'with' statement to open a file is considered best practice.
Reason (R): It ensures the file is automatically closed, even if an error occurs.
ANSWER KEY XII CS File Handling
1. b. Riya, Isha,
3. c. [Link](["Pencil","25"])
4. d. 1122
5. a. Line1
6. c. DE
7. a. Python
Rocks
8. c. 123
45
[Link](lst1 , myfile)
12. [Link]()
2. How are text files different from binary files in case of delimiter ? 2
3. Following code is written to display the total number of words present in the file 2
from a text file “[Link]”. Write statement 1 and 2 to complete the code.
def countwords():
s = open("[Link]","r")
f = [Link]()
__________________statement 1
count = 0
_______________statement 2
count = count + 1
print ("Total number of words:", count)
4. Write a function to display those lines which start with the letter “G” from the text 2
file “[Link]” Write statement 1 and statement 2 to complete the code.
def count_lines( ):
c=0
_____________________statement 1
line = [Link]()
for w in line:
_______________statement 2
print(w)
[Link]()
5. Fill in the blank : 2
a) ___________ is a process of storing data into files and allows to performs
various tasks such as read, write, append, search and modify in files.
b) The transfer of data from program to memory (RAM) to permanent storage
device (hard disk) and vice versa are known as __________.
6. Write a Python program to create a CSV file named [Link] and store data of 2
3 students (Name, Age, Class).
7. Write a program to read [Link] using DictReader and print names only. 2
9. Differentiate between CSV file and Text file in case retrieval of records from 2
output file?
3 Marks Question
10. Write a function that counts and display the number of 5 letter words in a text file 3
“[Link]“
11. Write a program to count the number of students in [Link] (excluding 3
header).
12. Write a program to read [Link] and display students older than 17. 3
Data Files
1 rb+ mode: 2
• Opens a file for both reading and writing in binary format.
• The file must already exist; otherwise, an error occurs.
• The file pointer is placed at the beginning of the file.
• Existing content is preserved, and writing will overwrite from the current
file pointer position.
wb+ mode:
• Opens a file for both reading and writing in binary format.
• If the file exists, it is truncated (emptied); otherwise, a new file is created.
• The file pointer is placed at the beginning of the file.
• Any existing content is lost, and writing starts from the beginning of the
file.
2 Text Files: 2
• Store data as a sequence of characters (like ASCII or Unicode).
• Each line is terminated by a special character (EOL), typically a
newline character (\n).
• These delimiters are used to separate lines of text, allowing for easy
reading and writing of textual data.
Binary Files:
• Store data as a stream of bytes, without character encoding or line
delimiters.
• There is no concept of "lines" in the same way as in text files.
• Binary files are typically used for storing data that is not intended
for human readability, such as images, audio, or program code.
def countRec():
f=open('[Link]','rb')
count=0
while True:
try:
record=[Link](f)
if record[2]>100000:
count=count+1
except EOFError:
break
[Link]()
return count
STACK
1. Stack implementation can be performed using a list in Python. (True / False) 1
2. The top operation does not modify the contents of a stack. (True / False) 1
3. The peek operation refers to accessing/inspecting the top element in the stack (True/False) 1
11. You have a stack named BooksStack that contains records of books. Each book record is 3
represented as a list containing book_title, author_name, and publication_year.
Write the following user-defined functions in Python to perform the specified operations on
the stack BooksStack:
● push_book(BooksStack, new_book): This function takes the stack BooksStack
and a new book record new_book as arguments and pushes the new book record
onto the stack.
● pop_book(BooksStack): This function pops the topmost book record from the
stack and returns it. If the stack is already empty, the function should display
"Underflow".
● peep(BookStack): This function displays the topmost element of the stack
without deleting it. If the stack is empty, the function should display 'None'.
12. Thushar received a message(string) that has upper case and lower-case alphabet. He want to 3
extract all the upper case letters separately .Help him to do his task by performing the
following user defined function in Python:
a. Push the upper case alphabets in the string into a STACK
b. Pop and display the content of the stack.
For example:
If the message is “All the Best for your Pre-board Examination” The output should be : E P B
A
13. Write a function in Python, Push(EventDetails) where , EventDetails is a dictionary 3
containing the number of persons attending the events–
{EventName : NumberOfPersons}. The function should push the names of those events in the
stack named ‘BigEvents’ which have number of persons greater than 200. Also display the
count of elements pushed o n to the stack.
For example: If the dictionary contains the following data:
EventDetails ={"Marriage":300, "Graduation Party":1500, "Birthday Party":80, "Get
together" :150}
The stack should contain :
Marriage Graduation Party
The output should be:
The count of elements in the stack is 2
14. A list of numbers is used to populate the contents of a stack using a function push(stack, data) 3
where stack is an empty list and data is the list of numbers. The function should push all the
numbers that are even to the stack.
Also write the function pop(stack) that removes and returns the top element of the stack on its
each call.
15. A list contains following record of a student: 3
[student_name, age, hostel]
Write the following user defined functions to perform given operations on the stack named
‘stud_details’:
(i) Push_element() - To Push an object containing name and age of students who live in hostel
“Ganga” to the stack
(ii) Pop_element() - To Pop the objects from the stack and display them. Also, display “Stack
Empty” when there are no elements in the stack.
For example:
If the lists of customer details are:
[“Barsat”,17,”Ganga”]
[“Ruben”, 16,”Kaveri”]
[“Rupesh”,19,”Yamuna”]
The output should be: [“Barsat”,17,”Ganga”]
Stack Empty
16. Write a function in Python PUSH_IN(L), where L is a list of numbers. From this list, push all 3
numbers which are multiple of 3 into a stack which is implemented by using another list.
17. Write a function in Python, Push(KItem),where KItem is a dictionary containing the details of 3
Kitchen items– {Item:price}. The function should push the names of those items in a stack
which have price less than 100. Also display the average price of elements pushed into the
stack.
For example:
If the dictionary contains the following data:
{"Spoons":116,"Knife":50,"Plates":180,"Glass":60}
The stack should contain
Glass
Knife
The output should be:
The average price of an item is 55.0
18. Given a Dictionary Stu_dict containing marks of students for three test-series in the form 3
Stu_ID:(TS1, TS2, TS3) as key-value pairs. Write a Python program with the following user-
defined functions to perform the specified operations on a stack named Stu_Stk
(i) Push_elements(Stu_Stk, Stu_dict) : It allows pushing IDs of those students, from the
dictionary Stu_dict into the stack Stu_Stk, who have scored more than or equal to 80
marks in the TS3 Test.
(ii) Pop_elements(Stu_Stk): It removes all elements present inside the stack in LIFO
order and prints them. Also, the function displays 'Stack Empty' when there are no
elements in the stack. Call both functions to execute queries.
For example: If the dictionary Stu_dict contains the following data:
Stu_dict ={5:(87,68,89), 10:(57,54,61), 12:(71,67,90), 14:(66,81,80), 18:(80,48,91)}
After executing Push_elements(), Stk_ID should contain
[5,12,14,18]
After executing Pop_elements(),
The output should be:
18
14
12
5
Stack Empty
19. Consider a list named Nums which contains random integers. 3
Write the following user defined functions in Python and perform the specified operations on
a stack named BigNums.
(1)PushBig(): It checks every number from the list Nums and pushes all such numbers which
have 5 or more digits into the stack, BigNums.
(ii) PopBig(): It pops the numbers from the stack, BigNums and displays them. The function
should also display "Stack Empty" when there are no more numbers left in the stack.
Nums [213,10025,167,254923,14,1297653,31498,386,92765)
Then on execution of PushBig(), the stack BigNums should store:
[10025, 254923, 1297653, 31498, 92765]
And on execution of PopBig (), the following output should be displayed:
92765
31498
1297653
254923
10025
Stack Empty
20. A dictionary, d_city contains the records in the following format: 3
(state:city)
Define the following functions with the given specifications:
(i) push_city (d_city): It takes the dictionary as an argument and pushes all the cities in the
stack CITY whose states are of more than 4 characters.
(ii) pop_city(): This function pops the cities and displays "Stack empty" when there are no
more cities in the stack.
SOLUTION Stack
Answers:
1. Ans. c
2. Ans. d
3. Ans. b
4. Ans. d
5. Ans. a
6. Ans. a
7. Ans. a
8. Ans. a
9. Ans. a
10. Ans. b
11. def push_book(BooksStack, new_book):
[Link](new_book)
def pop_book(BooksStack):
if len(BooksStack) == 0:
print("Underflow")
else:
return [Link]()
def peep(BooksStack):
if len(BooksStack) == 0:
print("None")
else:
print(BooksStack[-1])
return BooksStack[-1]
12. def push_uppercase(stack, message):
for char in message:
if [Link]():
[Link](char)
def pop_and_display(stack):
while stack:
print([Link](), end=' ')
print() # For newline after output
13. def Push(EventDetails):
BigEvents = [] # Stack to hold big event names
for event, persons in [Link]():
if persons > 200:
[Link](event)
# Display the stack
for event in BigEvents:
print(event)
# Display the count
print("The count of elements in the stack is", len(BigEvents))
14. def push(stack, data):
for num in data:
if num % 2 == 0:
[Link](num)
def pop(stack):
if len(stack) == 0:
return None # Or raise an error if preferred
return [Link]()
15. stud_details = [] # Stack initialized
def Push_element(student_list):
if student_list[2] == "Ganga":
stud_details.append(student_list)
def Pop_element():
if not stud_details:
print("Stack Empty")
else:
while stud_details:
print(stud_details.pop())
print("Stack Empty")
16. def PUSH_IN(L):
stack = []
for num in L:
if num % 3 == 0:
[Link](num)
return stack
17. def Push(KItem):
stack = []
total = 0
count = 0
for item, price in [Link]():
if price < 100:
[Link](item)
total += price
count += 1
# Display stack content
for i in stack:
print(i)
# Display average
if count > 0:
average = total / count
print(f"The average price of an item is {average}")
18. def Push_elements(Stu_Stk, Stu_dict):
for Stu_ID, marks in Stu_dict.items():
if marks[2] >= 80: # TS3 is the third test (index 2)
Stu_Stk.append(Stu_ID)
# Function to pop and print all elements from the stack
def Pop_elements(Stu_Stk):
while Stu_Stk:
print(Stu_Stk.pop())
print("Stack Empty")
# Main program
Stu_dict = {
5: (87, 68, 89),
10: (57, 54, 61),
12: (71, 67, 90),
14: (66, 81, 80),
18: (80, 48, 91)
}
Stu_Stk = []
# Perform operations
Push_elements(Stu_Stk, Stu_dict)
Pop_elements(Stu_Stk)
19. # Sample list of random integers
Nums = [213, 10025, 167, 254923, 14, 1297653, 31498, 386, 92765]
# Stack to hold numbers with 5 or more digits
BigNums = []
# Function to push big numbers (5 or more digits) to the stack
def PushBig():
for num in Nums:
if len(str(num)) >= 5:
[Link](num)
20. CITY = [ ]
# Function to push cities where the state has more than 4 characters
def push_city(d_city):
for state, city in d_city.items():
if len(state) > 4:
[Link](city)
# Function to pop cities from the stack
def pop_city():
while CITY:
print([Link]())
print("Stack empty")
TOPIC : COMPUTER NETWORKING
1. Quick Learn University is setting up its academic blocks at Prayag Nagar and planning to 5×1=5
set up a network. The university has 3 academic blocks and one human resource center
as shown in the diagram below:
As a Network Expert, need to suggest the best network-related solutions for them to
resolve the issues/problems mentioned in questions (i) to (v), keeping the following
parameters in mind :
Prayag Nagar
From To Distance
LAW BLOCK BUSINESS 40 m
BLOCK
LAW BLOCK TECHNOLOGY 80 m
BLOCK
LAW BLOCK HR BLOCK 105 m
BUSINESS TECHNOLOGY 30 m
BLOCK BLOCK
BUSINESS HR BLOCK 35 m
BLOCK
TECHNOLOGY HR BLOCK 15 m
BLOCK
Number of Computers in each block is as follows:
Block No. of Computers
LAW BLOCK 15
TECHNOLOGY BLOCK 40
HR CENTRE 115
BUSINESS BLOCK 25
2. Rehaana Medicos Center has set up its new center in Dubai. It has four buildings as 5×1=5
shown in the diagram below:
As a Network Expert, need to suggest the best network-related solutions for them to
resolve the issues/problems mentioned in questions (i) to (v), keeping the following
parameters in mind :
IT IoT
COIMBATORE
CAMPUS
DS
From To Distance
IT DS 28 m
IT IoT 55 m
DS IoT 32 m
KODAGU COIMBATORE 304 km
CAMPUS CAMPUS
As a Network Expert, need to suggest the best network-related solutions for them to
resolve the issues/problems mentioned in questions (i) to (v), keeping the following
parameters in mind:
(i) Suggest the most appropriate block/location to house the SERVER in the Kodagu
campus (out of the 3 blocks) to get the best and effective connectivity. Justify your
answer.
(ii) Suggest a device/software to be installed in the Kodagu Campus to take care of data
security.
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to most
efficiently connect various blocks within the Kodagu Campus.
(iv) Suggest the placement of the following devices with appropriate reasons: (a)
Switch/Hub (b) Router
(v) (a) Suggest a protocol that shall be needed to provide Video Conferencing solution
between Kodagu Campus and Coimbatore Campus.
OR
(b) What type of network (PAN, LAN, MAN, or WAN) will be set up among the
computers connected in above mentioned diagram?
4. Future Tech Corporation, a Bihar based IT training and development company, is 5×1=5
planning to set up training centers in various cities in the coming year. Their first center
is coming up in Surajpur district. At Surajpur center, they are planning to have 3 different
blocks - one for Admin, one for Training and one for Development. Each block has
number of computers, which are required to be connected in a network for
communication, data and resource sharing as shown in the diagram below:
As a Network Expert, need to suggest the best network-related solutions for them to
resolve the issues/problems mentioned in questions (i) to (v), keeping the following
parameters in mind :
Surajpur Centre
Development
block
Raipur
Training
block Admin block
(i) Suggest the most appropriate block/location to house the SERVER in the Surajpur
center (out of the 3 blocks) to get the best and effective connectivity. Justify your answer.
(ii) Suggest why should a firewall be installed at the Surajpur Center?
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to most
efficiently connect various blocks within the Surajpur Center.
(iv) Suggest the placement of the following devices with appropriate reasons: a)
Switch/Hub b) Router
(v) (a) Suggest the best possible way to provide wireless connectivity between Surajpur
Center and Raipur Center.
OR
(b) What type of network (PAN, LAN, MAN, or WAN) will be set up among the
computers connected in above mentioned diagram?
5. Ravya Industries has set up its new center at Kaka Nagar for its office and web-based 5×1=5
activities. The company compound has 4 buildings
as shown in the diagram below:
As a Network Expert, need to suggest the best network-related solutions for them to
resolve the issues/problems mentioned in questions (i) to (v), keeping the following
parameters in mind :
HARSH BUILDING
JAZZ BUILDING
1. Your school has four branches spread across the city. A computer network 1
created by connecting the computers of all the school branches, is a.
[Link] [Link] [Link] [Link]
2. A user gets an email asking to click a link and enter bank details. This is an 1
example of:
a. Spam b. Phishing c. Hacking d. Malware
3. The protocol used to transfer files over the Internet is: 1
a. FTP b. HTTP c. SMTP d. IP
A set of rules that governs data communication is knowni. as: 1
a. Topology b. Protocol c. Router d. Gateway
4. Which of the following is not a type of computer network? 1
a. LAN b. MAN c. WAN d. SANITIZE
5. Which device is used to connect different networks together? 1
a. Switch b. Router c. Hub [Link]
6. A user is watching a video on YouTube. Which protocol is primarily responsible 1
for data transmission?
a. FTP b. SMTP c. TCP/IP d. POP3
7. In which topology is each computer connected to a central hub? 1
a. Ring b. Bus c. Star d. Mesh
8. Which protocol is used to transfer web pages? 1
a. FTP b. HTTP c. SMTP d. IP
9. Which protocol is used to send emails? 1
a. HTTP b. FTP c. SMTP d. SNMP
10. Which of the following is used for wireless communication? 1
a. Ethernet b. Bluetooth c. USB d. HDMI
11. Which of the following is not a web browser? 1
a. Chrome b. Firefox c. Windows d. Safari
FULL FORMS Questions
13. What does ISP stand for? 1
14. What is the full form of URL? 1
15. What is the full form of Wi-Fi? 1
Assertion and Reasoning Questions
Directions: For each question, select the correct option:
(A) Both Assertion and Reason are true and Reason is the correct explanation of
Assertion.
(B) Both Assertion and Reason are true but Reason is NOT the correct
explanation of Assertion.
(C) Assertion is true but Reason is false.
(D) Assertion is false but Reason is true.
16. Assertion (A): Star topology is more reliable than bus topology. 1
Reason (R): In star topology, each device is connected to a central hub, reducing
dependence on a single cable.
17. Assertion (A): In ring topology, data moves in multiple directions. 1
Reason (R): Ring topology has multiple paths between nodes.
18. Assertion (A): SMTP is used to receive emails. 1
Reason (R): SMTP is a sending protocol, not a receiving protocol.
19. Assertion (A): Switch operates at the Data Link Layer of the OSI model. 1
Reason (R): Switch uses MAC addresses to forward data.
20. Assertion (A): In LAN, devices are spread over a large geographical area. 1
Reason (R): LAN is designed for short distances like within a building.
[Link]. Answers Marks
1. c. MAN 1
2. b. Phishing 1
3. a. FTP 1
4. b. Protocol 1
5. d. SANITIZE 1
6. b. Router 1
7. c. TCP/IP 1
8. c. Star 1
9. b. HTTP 1
10. c. SMTP 1
11. b. Bluetooth 1
12. c. Windows 1
FULL FORMS
13. Internet Service Provider 1
14. URL: Uniform Resource Locator 1
15. Wireless Fidelity 1
Assertion and Reasoning Questions
16. A) Both A and R are true and R is the correct explanation of A. 1
17. D) Assertion is false but Reason is true. 1
(In Ring topology, data moves in only one direction unless it’s a dual ring!)
18. D) Assertion is false but Reason is true. 1
19. A) Both A and R are true and R is the correct explanation of A. 1
20. D) Assertion is false but Reason is true. 1
Database & SQL
Q. No. Question Marks
Employee
TECH_COURSE
a. AVG(FEES) b. 15500
15500
c. AVG(FEES) d. All of these
15500.00
17 SELECT TID, COUNT(*), MIN(FEES) FROM TECH_COURSE GROUP BY 1
TID HAVING COUNT(TID) >1;
Answer Key
1 A 6 DDL – CREATE, ALTER 11 A 16 C
2 A 7 C 12 A 17 B
3 A 8 C 13 B 18 A
4 C 9 A 14 D 19 A
5 B 1 B 15 A 20 B
0
[Link]. MARKS
TABLE: GRADUATE_STUDENTS
S.N NAME STIPEND SUBJECT AVERAGE DIV
O
1 KARAN 400 PHYSICS 68 I
2 DIWAK 450 COMP Sc 68 I
AR
3 DIVYA 300 CHEMISTRY 62 I
4 REKHA 350 PHYSICS 63 I
5 ARJUN 500 MATHS 70 I
6 SABINA 400 CHEMISTRY 55 II
7 JOHN 250 PHYSICS 64 I
8 ROBERT 450 MATHS 68 I
9 RUBINA 500 COMP Sc 62 I
10 VIKAS 400 MATHS 57 II
a. List the names of those students who have obtained DIV I sorted by NAME.
[Link] a report, listing NAME, STIPEND, SUBJECT and amount of stipend
received in a year assuming that the STIPEND is paid every month.
c. To count the number of students who are either PHYSICS or COMPUTER SC
graduates.
[Link] insert a new row in the Graduate_students table: 11,”KAJOL”, 300, “computer sc”,
75, 1
2 Consider the table ORDERS as given below 4
TABLE- ORDER
a. Add a column REMARKS in the table with datatype as varchar with 50 characters.
b. Display the name, sub1, sub2, sub3 whose grade is IV.
c. Insert the following record into the table
Roll No- 108, Name- Aaditi, sub1- 470, sub2-444, sub3- 475, Grade– I.
d. Increase the sub2 marks of the students by 3% whose name begins with ‘N’.
4 Write SQL queries for (a) to (d) which are based on the tables TRANSPORT AND 4
JOURNEY.
Table: TRANSPORT
CODE VTYPE PERKM
101 VOLVO BUS 160
102 AC DELUXE BUS 150
103 ORDINARY BUS 90
105 SUV 40
104 CAR 20
Table: JOURNEY
NO NAME TDATE KM CO NOP
DE
101 Janish Kin 2015-11-13 200 101 32
103 Vedika 2016-04-21 100 103 45
Sahai
105 Tarun Ram 2016-03-23 350 102 42
102 John Fen 2016-02-13 90 102 40
107 Ahmed 2015-01-10 75 104 2
Khan
104 Raveena 2016-05-28 80 105 4
a. To display NO, NAME, TDATE from the table TRANSPORT in descending order
of NO.
b. To display the NAME of all the travellers from the table TRANSPORT who
are travelling by vehicle with code 101 or 102.
c. To display the NO and NAME of those travellers from the table TRAANSPORT
who travelled between ‘2015-12-31’ and ‘2015-04-01’.
d. To display all the details from table TRANSPORT for the travellers, who
have travelled distance more than 100 KM in ascending order of NOP?
5 Give output of the following queries as per given table(s): 4
TABLE- WORKER
TABLE- DEPT
ACode City
A01 Delhi
A02 Jaipur
A01 Ajmer
a. What will be the output of the following statement?
SELECT * FROM BANK_ACCOUNT NATURAL JOIN BRANCH;
(B) Give the output of the following sql statements as per table given above-
TABLE: SPORTS
101 Anjali 12 A 85
102 Rohan 12 B 92
103 Meera 12 A 78
104 Aditya 12 C 88
105 Arun 12 C 89
TABLE- FEE
RollNo AmountPaid PaymentDate
a. Display the names of all students along with the amount of fee they have paid.
b. Display the names of students who paid the fee between '2024-04-15' and '2024-04-
17'.
c. List names of students who belong to section 'a' and have paid more than 25000.
d. List the names of students who have not paid the fee yet.
9 consider the following tables EMPLOYEE and PROJECT and answer the following 5
questions
EMPLOYEE
EmpID Name Department Salary
PROJECT
ProjectID EmpID Project Name HoursWorked ProjectID
a. Display all employees along with the projects they are working on.
b. List names of employees who are working on more than one project.
c. Show the total hours worked by each employee.
d. List all employees and their project names, including those who are not working on
any project.
e. Display names and departments of employees who have worked more than 30 hours
in any project.
10 consider the following tables EMPLOYEE and DEPARTMENT and answer the 4
following questions-
EMPLOYEE
EmpID Name Salary DeptID
DEPARTMENT
DeptID DeptName Location DeptID
d. SELECT SUM(Price) AS
Total_Price_Null_Quantity
FROM ORDERS
WHERE Quantity IS NULL;
OR
(B)
a. C_Name Total Quantity
Jitendra 1
Mustafa 2
Dhwani 1
Alice 1
David NULL
b.
O_Id C_Name Product Quantity Price
1002 Mustafa Smartphone 2 10000
1004 Alice Smartphone 1 9000
c.
4
3 a. New Degree: 8 New Cardinality: 5
b. SELECT name,sub1,sub2,sub3
FROM RESULT
WHERE GRADE=’IV’,
c. A) INSERT INTO RESULT VALUES (108, ‘Aadit’, 470, 444, 475, ‘I’);
d. UPDATE RESULT SET SEM2=SEM2+ (SEM2*0.03)
WHERE SNAME LIKE “N%”;
OR (Option for part iii only)
a. DELETE FROM RESULT WHERE DIV=’IV’;
OR
SELECT NO, NAME from TRAVEL WHERE TDATE BETWEEN ‘2015-04-01’ AND
‘2015-12-31’;
5 a. JOB 4
CLERK
ELECTRICIA
N FITTER
GUARD
b.
DNAME LOC
PRODUCTION GROUND FLOOR
SECURITY 1ST FLOOR
c.
WNAME MANAGER
RAHUL SHARMA R KSINGH
MUKESH VYAS D K JAIN
SURESH S ARORA
ANKUR D K JAIN
d. WNAME
RAHUL SHARMA
6 a. Vice principal 01 4
b. 16
c. UMESH YASHRAJ
d.
5 Male
2 Female
3
7 (A) a.
ACode Name Type City
A01 Amit Savings Delhi
A01 Amit Savings Ajm
er
A02 Parth Current Jaip
ur
(B)-a. 6
b.
Class
7
8
9
10
c.10
d.
Game1 Count(*)
Cricket 2
Tennis 2
Swimming 1
8 a. SELECT STUDENT. Name, [Link] 4
FROM STUDENT
LEFT JOIN FEE ON [Link] = [Link];
b. SELECT STUDENT. Name
FROM STUDENT
INNER JOIN FEE ON [Link] = [Link]
WHERE [Link] BETWEEN '2024-04-15' AND '2024-04-17';
c. SELECT STUDENT. Name
FROM STUDENT
INNER JOIN FEE ON [Link] = [Link]
WHERE STUDENT. Section = 'A' AND [Link] > 25000
d. SELECT STUDENT. Name
FROM STUDENT
LEFT JOIN FEE ON [Link] = [Link]
WHERE [Link] IS NULL;
a. SELECT [Link], [Link] 5
9 FROM EMPLOYEE
INNER JOIN PROJECT ON [Link] = [Link];
b. SELECT EMPLOYEE. Name, COUNT([Link]) AS ProjectCount
FROM EMPLOYEE
INNER JOIN PROJECT ON [Link] = [Link]
GROUP BY EMPLOYEE. Name
HAVING COUNT([Link]) > 1;
c. SELECT EMPLOYEE. Name, SUM([Link]) AS TotalHours
FROM EMPLOYEE
INNER JOIN PROJECT ON [Link] = [Link]
GROUP BY [Link];
d. SELECT [Link], [Link]
FROM EMPLOYEE
LEFT JOIN PROJECT ON [Link] = [Link];
d. SELECT [Link], [Link]
FROM EMPLOYEE
INNER JOIN PROJECT ON [Link] = [Link]
WHERE [Link] > 30;
10 a. SELECT [Link], [Link], [Link], 4
[Link]
FROM Employee
JOIN Department ON [Link] = [Link];
b. SELECT [Link]
FROM Employee
JOIN Department ON [Link] = [Link]
WHERE Department. Location = 'Delhi';
c. SELECT Name, Salary
FROM Employee
WHERE Salary = (SELECT MAX(Salary) FROM Employee);
d. SELECT [Link], AVG([Link]) AS AvgSalary
FROM Employee
JOIN Department ON [Link] = [Link]
GROUP BY [Link];
Python-MySQL Connectivity
The fetchone() method returns results as a dictionary. (Find True or False) 1
(Q1
Q2 MySQL connector must be installed using pip install mysql. (Find True or False) 1
Ans2 False
Ans3 execute().
Ans5 d All
Ans6 a [Link]()
Ans7 b. fetchone()
Ans8 a) connect()
Ans9 c. con.is_connected()
Ans10 a