Xii Comdec Set A
Xii Comdec Set A
10. Write the missing statement to complete the following code: (1)
file = open("example.txt", "r")
data = file.read(100)
#Move the file pointer to the
beginning of the file
next_data = file.read(50)
file.close()
12. Which SQL command can change the degree of an existing relation? (1)
14 In which datatype the value stored is padded with spaces to fit the specified
length.
(1)
(A) DATE (B)VARCHAR (C)FLOAT (D)CHAR
Q17 and Q18 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 for A
(B) Both A and R are true and R is not the correct explanation
for A
(C) A is True but R is False
(D) A is False but R is True
18. Assertion (A): A SELECT command in SQL can have both WHERE and
HAVING clauses.
Reasoning (R): WHERE and HAVING clauses are used to check (1)
conditions, therefore, these can be used interchangeably.
20. Observe the following code carefully and rewrite it after removing all
syntactical errors. Underline all the corrections made. (2)
def 1func():
a=input("Enter a number"))
if a>=33
print("Promoted to next class")
ELSE:
print("Repeat")
21 If L1=[1,2,3,2,1,2,4,2, . . . ], and L2=[10,20,30, . . .],
(2)
Then (Answer using builtin functions only)
A) Write a statement to sort the elements of list L1 in ascending order.
B) Write a statement to reverse the elements of list L2.
(2)
22 Identify the correct output(s) of the following code. Also write the minimum
and the maximum possible values of the variable b.
import random
a="Wisdom"
b=random.randint(1,6)
for i in range(0,b,2):
print(a[i],end='#')
Write a method SHOWLINES() in Python to read lines from text file (3)
26.
“TESTFILE.TXT‟ and display the lines which do not contain 'ke' and also do
not end with vowel.
Example: If the file content is as follows:
An apple a day keeps the doctor aside.
We all pray for everyone‟s safety.
A marked difference will come in our country.
The SHOWLINES() function should display the output as:
We all pray for everyone‟s safety.
OR
Write a function RainCount() in Python, which should read the content of a
text file “TESTFILE.TXT” and then count and display the count of occurrence
of independent word RAIN (case-insensitive) in the file.
Example: If the file content is as follows:
It rained yesterday
It might rain today
I wish it rains tomorrow too
I love Rain
The RainCount() function should display the output as: Rain -2
You have a stack named BooksStack that contains records of books. Each 3
27
book record is 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:
(I)push_book(BooksStack, new_book): This function takes the stack
BooksStack and a new book record new_book as arguments and
31 Consider the table ORDERS as given below and Write the output
(4)
(I) Write a function to input the data of a candidate and append it in a binary
file.
(II)Write a function to update the data of candidates whose experienceis
more than 10 years and change their designation to "Senior Manager".