Page 34 - PYTHON-12
P. 34
27. I. (a) What constraint should be applied on a table column to ensure that all entries are different but the
column still accepts NULL values? (2)
OR
(b) What constraint should be applied to establish a relationship between two tables, ensuring that the
values in a specific column of one table correspond to existing values in the column of another
table?
II. (a) Write the SQL command to add a NOT NULL constraint to the column NAME in a table called
VENDORS.
OR
(b) Write the SQL command to add a DEFAULT value of ‘Pending’ to the STATUS column in a table
called FEES.
28. (a) Write any two advantages of fibre optic cable. (2)
OR
(b) What does VoIP stand for? What is its use?
Section C
29. (a) Write a Python function called find_longest_word(filename) that reads a text file and returns the longest
word found in the file. If there are multiple longest words, return one of them. (3)
OR
(b) Write a Python function named reverse_lines(filename) that reads a text file and writes a new file where
the order of the lines is reversed.
30. (a) You have a Stack named CustomerStack that contains records of customers. Each customer record is
represented as a list containing customer_id, customer_name and contact_number.
Write the following user-defined functions in Python to perform the specified operations on the Stack
CustomerStack: (3)
(i) push_customer(CustomerStack, new_customer): This function takes the Stack CustomerStack and
a new customer record new_customer as arguments and pushes the new customer record on to
the Stack.
(ii) pop_customer(CustomerStack): This function pops the topmost customer record from the Stack
and returns it. If the Stack is already empty, the function should display ‘Underflow’.
(iii) peek(CustomerStack): This function displays the topmost element of the Stack without deleting it.
If the Stack is empty, the function should display ‘None’.
OR
(b) Write the definition of a user-defined function Push_div5(N) which accepts a list of integers in a
parameter ‘N’ into a Stack named DivisibleBy5.
Write function Pop_div5() that pops the topmost number from the Stack and returns it. If the Stack is
already empty, the function should display ‘Empty’.
Write function Display_div5() to display all elements of the Stack without deleting them. If the Stack is
empty, the function should display ‘None’.
31. Predict the output of the following code: (3)
(a) student_marks = {'Alisha': 95,'Bhavesh': 80,'Charvi': 68,'Diva': 92}
for student in student_marks:
student_marks[student] -= 2
print("Updated scores:", student_marks)
top_marks = max(student_marks.values())
print("Highest score:", top_marks)
top_student = max(student_marks, key=student_marks.get())
print("Top student:", top_student)
OR
Appendices A.49