xii pre board set 1
xii pre board set 1
General Instructions:
.
Section A
string = "HELLOCS"
string = string.lower().replace('o', 'x')
print(string)
(A) Helxlcs (B) HELXLCS (C) helxocs (D) None of the
above
4.Given a list nums = [10, 20, 30, 40], what will nums[-3:] return?
(A) [10, 20, 30] (B) [20, 30, 40] (C) [30, 40] (D) None of the above
5. What will be the output of the following code snippet?
tuple1 = (1, 3, 5)
tuple2 = (7,)
1
tuple3 = tuple1 + tuple2
print(len(tuple3))
(A)3 (B) 4 (C) Error (D) None of the above
6.Which of these is not a valid Python keyword?
(A) with (B) async (C) module (D) del
Section B
22.Explain the difference between a primary key and a foreign key in SQL.
23.Write a Python code snippet to count the number of vowels in the string "COMPUTER".
24.How are dictionaries different from lists in Python?
25.Write a Python function to reverse a list in-place.
26. What will be the output of this code?
import random
num = random.randint(2, 5)
print("Number:", num)
27. Write a SQL query to fetch all records from a table.
28. If
L1 = [1, 2, 3, 2, 1, 2, 4, 2, ...],
3
L2 = [10, 20, 30, ...]
(I)
A) Write a statement to count the occurrences of 4 in L1.
OR
B) Write a statement to sort the elements of list L1 in ascending order.
(II)
A) Write a statement to insert all the elements of L2 at the end of L1.
OR
B) Write a statement to reverse the elements of list L2.
Section C
29.. Write a Python function to read a file "data.txt" and display all lines that contain the
word "Python".
30.Write a Python function push_even(numbers) to push even numbers from a given list
into a stack and display the stack.
31.Predict the output of the following Python code:
def modify_list(lst):
for i in range(len(lst)):
lst[i] = lst[i] ** 2
numbers = [1, 2, 3]
modify_list(numbers)
print(numbers)
Section D (4 x 4 = 16 Marks)
4
Write Python functions to:
a. Count the total number of happy people in the file.
b. Display all records where the age is greater than 30.
34.A table, named EMPLOYEES, in the COMPANYDB database, has the following
structure:
Field Type
empID int(11)
empName varchar(30)
salary float
department varchar(20)
AddAndDisplay():
Host: localhost
User: root
Password: password
Database: COMPANYDB
35.Samantha has been entrusted with the management of a School Database. She needs to
access some information from the STUDENTS and ENROLLMENTS tables for an
analysis. Help her extract the following information by writing the desired SQL queries as
mentioned below.
Table: STUDENTS
Table: ENROLLMENTS
SQL Queries:
(I) To display the complete details (from both the tables) of those students whose
grade is 'A'.
(II) To display the details of courses (from the ENROLLMENTS table) where the
enrollment status is 'Active'.
(III) To update the status of all students who are enrolled in a course with C_ID = 101
to 'Inactive'.
(IV)
(A) To display the names (SName) of students who are enrolled in course C_ID = 101.
OR
(B) To display the Cartesian product of the STUDENTS and ENROLLMENTS tables.
Section E (2 x 5 = 10 Marks)
Engineer_ID – integer
Engineer_Name – string
Programming_Language – string
Years_of_Experience – float
You, as a software developer at the company, have been assigned to implement the required
functionality for Alex.
(I) Write a function to input the data of an engineer and append it to a binary file.
(II) Write a function to update the data of engineers whose experience is more than 5 years
and change their programming language to "Python".
(III) Write a function to read the data from the binary file and display the data of all those
engineers who are not using "Python" as their programming language.
6
37. The company is expanding its infrastructure across two cities: London and New York.
Both cities have software development teams that need to be connected efficiently. You, as a
network expert, are tasked with providing network-related solutions for them.
From To Distance
Admin Development 50 m
Admin Design 30 m
Development Design 60 m
Testing Admin 70 m
New York Office London Office 5000 km
7
8