Kaish Sample Paper
Kaish Sample Paper
In Python, objects are categorized as mutable or immutable based on whether their values
can be changed after creation.
Mutable Objects: These objects can be changed after they are created. Their contents
(elements or attributes) can be modified without changing the object’s identity
(memory address).
Immutable Objects: These objects cannot be changed after they are created. Any
modification results in the creation of a new object in memory.
Final Answer
Arithmetic operators are used to perform mathematical operations like addition, subtraction,
multiplication, etc.
Examples:
1. Addition (+) → 5 + 3 = 8
2. Multiplication (*) → 4 * 2 = 8
Relational operators (also called comparison operators) are used to compare two values and
return True or False.
Examples:
OR
sorted_L1 = sorted(L1)
OR
reversed_L2 = L2[::-1]
Possible Values of b
Since b is chosen randomly from {1, 2, 3, 4, 5, 6}, the minimum possible value is 1,
and the maximum is 6.
Loop Behavior
Checking Outputs
Final Answer:
26. Here is the corrected version of the code, with errors underlined and fixed:
Corrected Code:
def swap_first_last(tup): # **Fixed missing colon**
if len(tup) < 2:
return tup # **Fixed indentation**
new_tup = (tup[-1],) + tup[1:-1] + (tup[0],) # **Fixed tuple
creation**
return new_tup
Expected Output:
Swapped tuple: (4, 2, 3, 1)
The UNIQUE constraint ensures that all values in the column are distinct, but it allows NULL values.
OR
The NOT NULL constraint ensures that the column cannot have NULL values, but duplicates are
allowed.
OR
✅ Advantage:
Easy to troubleshoot and maintain – Since all devices are connected to a central hub, it is
easier to identify and fix issues.
❌ Disadvantage:
Single point of failure – If the central hub or switch fails, the entire network goes down.
B) SMTP
✅ Use:
SMTP is used for sending emails over the internet. It facilitates communication between email
clients and mail servers to deliver outgoing messages.
Explanation:
Explanation:
31. Here are the Python implementations for both (A) Stack Operations for BooksStack and (B)
Stack Operations for Even Numbers.
# Example Usage
BooksStack = []
push_book(BooksStack, ["The Great Gatsby", "F. Scott Fitzgerald", 1925])
push_book(BooksStack, ["To Kill a Mockingbird", "Harper Lee", 1960])
push_book(BooksStack, ["1984", "George Orwell", 1949])
# Function to display all even numbers in the stack without deleting them
def Disp_even():
if not EvenNumbers: # Check if stack is empty
print(None)
else:
print(EvenNumbers)
# Example Usage
VALUES = [10, 5, 8, 3, 12]
push_even(VALUES) # Store even numbers in stack
Both implementations follow stack principles (LIFO - Last In, First Out) and handle edge cases like
underflow conditions. 🚀
1. d is a dictionary:
json
CopyEdit
{"apple": 15, "banana": 7, "cherry": 9}
2. Loop Iteration:
o For "apple", str1 = "15@\n"
o For "banana", str1 = "15@\n7@\n"
o For "cherry", str1 = "15@\n7@\n9@\n"
3. str2 = str1[:-1], which removes the last newline \n, resulting in:
"15@\n7@\n9@"
15@
7@
9@
Final Answers:
15@
7@
9@
1 #2 #3 #
1 #2 #3 #
1 #
✅ Explanation:
(II) Display the Orders table sorted by total price (Quantity * Price) in
descending order:
SELECT *, (Quantity * Price) AS Total_Price
FROM Orders
ORDER BY Total_Price DESC;
✅ Explanation:
(III) Display distinct customer names ( C_Name) from the Orders table:
SELECT DISTINCT C_Name FROM Orders;
✅ Explanation:
(IV) Display the sum of Price for orders where Quantity is NULL:
SELECT SUM(Price) AS Total_Price_Null_Quantity
FROM Orders
WHERE Quantity IS NULL;
✅ Explanation:
C_Name | Total_Quantity
-------------------------
Jitendra | 1
Mustafa | 2
Dhwani | 1
...
✅ Output:
✅ Output:
markdown
CopyEdit
MAX(Price)
12000
33. (I) Read and Display Records Where Population > 5,000,000
import csv
def display_large_population():
with open("Happiness.csv", "r") as file:
reader = csv.reader(file)
for row in reader:
country, population, sample_size, happy = row
if int(population) > 5000000:
print(row)
✅ Explanation:
✅ Explanation:
If "Happiness.csv" contains:
Country,Population,Sample_Size,Happy
Signiland,5673000,5000,3426
Happyland,3000000,4000,2900
Joytopia,8000000,6000,4900
Expected Output:
['Signiland', '5673000', '5000', '3426']
['Joytopia', '8000000', '6000', '4900']
Total Records: 3
34. (I) Display complete details (from both tables) for faculties whose salary is
less than 12000.
SELECT FACULTY.*, COURSES.*
FROM FACULTY
LEFT JOIN COURSES ON FACULTY.F_ID = COURSES.F_ID
WHERE FACULTY.Salary < 12000;
✅ Explanation:
(II) Display details of courses where Fees is between 20000 and 50000 (both
inclusive).
SELECT * FROM COURSES
WHERE Fees BETWEEN 20000 AND 50000;
✅ Explanation:
✅ Expected Output:
(III) Increase the fees of all courses by 500 that have "Computer" in their
course name.
UPDATE COURSES
SET Fees = Fees + 500
WHERE CName LIKE '%Computer%';
✅ Explanation:
✅ Affected Courses:
(A) Display faculty names (FName, LName) who are teaching System Design.
SELECT FName, LName
FROM FACULTY
WHERE F_ID = (SELECT F_ID FROM COURSES WHERE CName = 'System Design');
✅ Expected Output:
FName | LName
------------------------
Sulekha | Srivastava
✅ Explanation:
This will produce all possible combinations of rows from FACULTY and COURSES (Cross Join).
35. Here’s the Python function to connect to the ITEMDB database, insert an item into the
STATIONERY table, and then display records where the price is greater than 120.
def AddAndDisplay():
try:
# Establish connection to MySQL database
conn = mysql.connector.connect(
host="localhost",
user="root",
password="Pencil",
database="ITEMDB"
)
cursor = conn.cursor()
finally:
# Close connection
if conn.is_connected():
cursor.close()
conn.close()
print("Database connection closed.")
Explanation:
Example Run:
User Input:
Enter Item Number: 101
Enter Item Name: Notebook
Enter Price: 150
Enter Quantity: 5
Expected Output:
Item added successfully!
We will store candidate data in a binary file named "candidates.dat", using the pickle module.
import pickle
def add_candidate():
try:
# Open file in append-binary mode
with open("candidates.dat", "ab") as file:
Candidate_ID = int(input("Enter Candidate ID: "))
Candidate_Name = input("Enter Candidate Name: ")
Designation = input("Enter Designation: ")
Experience = float(input("Enter Experience (in years): "))
except Exception as e:
print("Error:", e)
✅ Explanation:
def update_designation():
try:
candidates = []
except Exception as e:
print("Error:", e)
✅ Explanation:
except FileNotFoundError:
print("File not found! Please add some candidate records first.")
except Exception as e:
print("Error:", e)
✅ Explanation:
Reads the file and displays candidates who are NOT "Senior Manager".
Handles file errors (e.g., if file doesn’t exist).
Example Run:
It has the highest number of computers (30), which ensures fastest access for the majority
of users.
The ADMIN block is centrally located, minimizing latency and ensuring efficient
communication with other blocks.
Most administrative tasks and data management are likely to be handled here.
A Switch should be used in each building to connect all computers within that block because:
Switches allow faster and efficient communication between multiple devices.
They reduce network congestion and allow for full-duplex communication (simultaneous
send/receive).
They support high-speed LAN (Local Area Network) connections.
(III) Cable Layout & Best Cable Choice for Efficient Data Transfer
1. Use Fiber Optic Cable as the backbone to connect all four buildings because it provides
high-speed, long-distance transmission with minimal data loss.
2. Use CAT6 Ethernet cables within each building to connect computers to the switch.
The longest distance between any two blocks is 96 meters (ADMIN ↔ MEDIA), which is
well within the limit for fiber optic cables (~2 km before signal degradation).
Fiber optic cables provide low signal attenuation over short distances.
The Mumbai campus will have a LAN (Local Area Network) because:
o All computers are within a single geographical location.
o The distance between buildings is under 100 meters, making LAN the most efficient
choice.
o LAN allows fast data transfer with low latency.
Best Communication
Video Conferencing Real-time, face-to-face communication
with Delhi