24-11-24 MODEL-IV Marks:70 Time:2.
30 hours
Section A
1. Which type of data structure does the following statement indicate? (1)
Student = ('Rollno:',10, 'Name:', 'Rajat Jain', 'Fees:',75000)
(a) Dictionary (b) Tuple (c) List (d) String
2. Complete the given MySQL statement with the correct option for the query to sort and display
the
records of items on the basis of their price in descending order and item_name alphabetically?
(1)
Select * from Product
order by price ________, item_name _________;
(a) Ascending, Descending (b) asc, desc (c) desc, asc (d) max, min
3. Given: (1)
x=12
x=x/5
print(type(x))
What will be the output of the above code? What is the name of the conversion used in this
example?
4. Rinku wrote a program to print sum of first 20 odd numbers. Help her complete the blanks: (1)
sum=0
a=1
while a<21:
_____________ # statement to add data to sum
_____________ # statement to continue the loop
print("Sum=", sum)
5. Rahul wants to give a command to count non-existing value in commission attribute of staff
table in
MySQL. Help him complete the command: (1)
select count(commission) from staff where ________________;
6. Which of the following is not a network device? (1)
(a) Firewall (b) Router (c) Bridge (d) Gateway
7. Consider a Dictionary of months and number of days: (1)
D={"January":31,"Feburary":28,"March":31,"April":30,
"May":31,"June":30,"July":31,"August":31,"September":30,
"October": 31,"November":30,"December":31}
Give command to:
(a) Display all the months
(b) Display all the days
8. Give the output of the following program segment: (1)
x="hello World"
print(x[:-2])
print(x[-2:])
9. Consider a tuple of marks of students, T=(78,89,90,44,89,95,39,45,78,44). Give command
to: (1)
(a) Display average of tuple T
(b) Display how many students scored 89 marks
10. In the context of Python-Database connectivity, rowcount is a/an— (1)
(a) attribute (b) method (c) object (d) literal
11. Identify the domain name and URL from the following: (1)
http://www.helpingeachother.in/aboutus.htm
12. Is the following code correct? If yes, what will be the output of the following code? (1)
s="-". join(("one","two","three"))
print(s)
13. “Trying to add an element to a full stack results in an exception termed as Overflow.” (True or
False) (1)
14. “Update command in MySQL is used to display unique values from a column.” (True or
False) (1)
15. Give full form of the following: (1)
(a) VoIP (b) POP
16. For a binary file, seek()method accepts: (1)
(a) Exactly one parameter (b) Exactly two parameters
(c) At most one parameter (d) At most two parameters
Q.17 and 18 are Assertion and Reasoning based questions. Mark the correct choice as:
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true but R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17. Assertion (A): [1, 2, 3] is an invalid key for a dictionary in Python.
Reason (R): Only numbers and strings can be the keys of a dictionary in Python. (1)
18. Assertion (A): CSV (Comma Separated Values) is a file format for data storage which looks
like a text file.
Reason (R): The information is organized with one record on each line and each field is
separated by
semicolon. (1)
Section B
19. (a) Name the fastest wired and wireless medium of communication. (1+1=2)
(b) Compare circuit and packet switching
20. Rewrite the following code in Python after removing all the error(s). Underline each
correction done in the
code. (2)
def Sum(Count)
S=0
for I in Range(1,Count+1):
S+=I
RETURN S
print(Sum[2])
print(Sum[5])
21. Find and write the output of the following Python code: (2)
def Display(str):
m=""
for i in range(0,len(str)):
if i%2 ==0:
m=m+str[i].lower()
else:
m=m+str[i].upper()
print(m)
Display('Program@Class12')
22. What possible output(s) is expected to be displayed on screen at the time of execution of
the program from
the following code? Justify your answer. (2)
import random
alpha=['T','U','V','W']
dig=[2,6,7,3]
print('The Winner is : ',end=" ")
print(alpha[random.randint(0,3)],end=" ")
for i in range(4):
print(dig[i+random.randint(0,2)],end=" ")
(a) The Winner is : T 7 3 6 (b) The Winner is : W 2 6 7 5
(c) The Winner is : V 6 6 0 (d) The Winner is : U 2 7 3
23. Predict the output of the Python code given below: (1 + 1 = 2)
def JDI(N1,N2=1):
if type(N1)==list:
return N1[N2]
else:
return N1-N2
print(N1,N2,sep='#',end=' ')
NUM=[15,20]
NUM.append(JDI(NUM,0))
NUM.append(JDI(10))
print(NUM)
Predict the output of the Python code given below:
d1={'a':1,'p':2,'p':3,'l':4,'e':5}
t1 ='apple','papaya', 'lemon', 'peach','mango'
i=0
for j in d1:
d1[j]=t1[i]
i+=1
print(d1)
24.a) Ms. Bhawna is a school librarian. She has to enter the records of the newly purchased
books in the‘Book’ table. Help her write a small Python program to insert a record in the table
Book with attributes
(title, isbn) (2)
25. Convert the following for loop to while loop: (2)
sum=0
for a in range(1,50):
if a%2==1:
sum+=a
else:
sum+=a**2
print(sum)
Section C
26. Write a function SetArray(ARR) in Python, which accepts a list Arr of numbers. The function
should shift all the negative values to left and all the positive values to right. (3)
Sample Input Data of the list Arr= [ –2, 3, –1, 4, –5, 7, –9, 6]
27. Write a SQL statement to create the following table HOSPITAL. (3)
Table: HOSPITAL
PNo Name Age Department DateofAdm Charges Sex
1 Sandeep 65 Surgery 1998-02-23 300 M
2 Ravina 24 Orthopaedic 1998-01-01 200 F
3 Karan 45 Orthopaedic 1998-02-19 200 M
4 Tarun 12 Surgery 1998-01-01 300 M
5 Zubin 36 ENT 1998-01-12 250 M
6 Ketaki 16 ENT 1998-02-24 300 F
7 Ankita 29 Cardiology 1998-02-20 800 F
8 Zareena 45 Gynaecology 1998-02-22 300 F
9 Kush 19 Cardiology 1998-01-13 800 M
10 Shaily 31 Medicine 1998-02-19 400 M
Note: PNo is the primary key in the above table.
Table: HOD
Department HOD_name
Surgery Rajesh Jain
Cardiology K.K. Arora
Medicine Ishan Arora
Gynaecology Shruti Bhatia
Orthopaedic Ram Khosla
ENT Meena Kumar
Write SQL commands for the statements (a) to (c) on the basis of the table HOSPITAL:
(a) To display the name of female patients admitted in Orthopaedic or ENT department.
(b) To count and display the no. of patients with more than 35 years of age.
(c) To display the patients who are admitted in the hospital and are treated by any HOD.
28. Write a function convert() in Python that copies contents of S.txt to NS.txt after converting
first letter
of every line to capital. (3)
Example, If the file "S.txt"contents are as follows:
this is a File
this is a new File
python can create files
this is a text file
then file "NS.txt" should have:
This is a File.
This is a new File
Python can create files
This is a text file
29. Write SQL queries based on the following two tables: (3)
Table: ACTIVITY
Acode ActivityName Stadium Participant Prize Date
1001 Relay 100 x 4 Star Annex 16 10000 2004-01-23
1002 High Jump Star Annex 10 12000 2003-12-12
1003 Shot Put Super Power 12 8000 2004-02-14
1005 Long Jump New Day 12 9000 2004-01-01
1008 Discuss Throw Star Annex 10 15000 2004-03-12
Table: COACH
Pcode Name Acode
P1 Ahmed Hussain 1001
P2 Ravinder 1008
P3 Jasmine 1002
P4 Naaz 1003
(a) Display the sum of Prize for the activities played in each of the stadiums separately.
(b) Display the content of Activity table whose Schedule Date is earlier than 2004-01-01 in
ascending
order of number of Participants.
(c) Display the name of activity and its corresponding coach name.
30. Write a program to create a STACK in which
A function named opPush to insert (PUSH) a newelement in stack. This function has two
parameters- the name of the stack in which the element is to be inserted (glassStack) and the
element that needsto be inserted
A function named opPop to delete the topmost element from the stack. It takes one parameter -
thename of the stack (glassStack) from which elementis to be deleted and returns the value of
the deleted element
• A functionnamed displayto show the contents of the stack (3)
Section D
31. A sports club manager, Mr. Ajeet Singh is maintaining data of their members in a table (1 × 4
= 4)
• Name of database: Sports
• Name of the Table: MEMBER
• Attributes of table MEMBER:
Member_id – Character of size 5
Member_name – Character of size 20
Address – Character of size 12
Age – Numeric
Fees – Numeric
Table: MEMBER
Member_id Member_name Address Age Fees
M001 Ajay ModelTown 48 3500
M002 Dilip Ashok Vihar 34 4000
M003 Nisha Gurgaon 31 4200
M004 Sachin Dwarka 27 4500
M005 Sanchit Ashok Vihar 32 3700
(a) Identify the attribute best suited to be declared as a primary key of table MEMBER.
(b) Write the degree and cardinality of the table MEMBER.
(c) Insert the following data into the table MEMBER.
Member_id:'M006',Member_name:'Harshit' ,Address: 'Faridabad', Age:30, Fee:3400
(d) What command Mr. Ajeet Singh should give to add a new column Game in the above table.
32. Pranav wants to create a csv file having teacher_code, teacher _name and subject in the
form of a List .Write functions add_teacher() to create the file teacher.csv and display() to
display teachers teaching “ CS” (1 × 4 = 4)
Section E
33. Quick Learn University is setting up its Academic blocks at Prayag Nagar and planning to set
up a network.
The university has 3 Academic blocks and one Human Resource Centre (5)
Business Block Technology Block
Law Block Human Resource R Centre
Centre-to-centre distance between various blocks is as follows:
Law block to business block 40 m
Law block to technology block 80 m
Law block to HR Centre 105 m
Business block to technology block 30 m
Business block to HR Centre 35 m
Technology block to HR Centre 15 m
Law block 15
Technology block 40
HR centre 115
Business block 25
(a) Suggest a cable layout of connection between the blocks.
(b) Suggest the most suitable place to house the server of the organization giving suitable
reason.
(c) Which device should be placed/installed in each of these blocks to efficiently connect all the
computers
within these blocks?
(d) Suggest the placement of a Repeater in the network with justification.
(e) The university is planning to link its sales counters situated in various parts of the same city.
Which type
of network out of LAN, MAN or WAN will be formed?
34. Surya is a manager working in a recruitment agency. He needs to manage
the records of various candidates. For this, he wants the following
information of each candidate to be stored:
- Candidate_ID – integer
- Candidate_Name – string
- Designation – string
- Experience – float
You, as a programmer of the company, have been assigned to do this job
for Surya.
(I) Write a function to input the data of a candidate and append it in a binary file. (5)
(II) Write a function to update the data of candidates whose experience is more than 10 years
and change their designation to "Senior Manager".
(III) Write a function to read the data from the binary file and display the data of all those
candidates who are not "Senior Manager"
35. A table, named STATIONERY, in ITEMDB database, has the following
structure:
Field Type
itemNo int(11)
itemName varchar(15)
price float
qty int(11)
Write the following Python function to perform the specified operation:
AddAndDisplay(): To input details of an item and store it in the table STATIONERY.
The function should then retrieve and display all recordsfrom the STATIONERY table where the
Price is greater than 120.
Assume the following for Python-Database connectivity:
Host: localhost, User: root, Password: Pencil (4)