KENDRIYA VIDYALAYA WALTAIR
JULY MONTHLY TEST – 2022-23
CLASS
XII SUBJECT: CS
MARKS 25 TIME 90 MINS
Answer all the questions
|
1 |
Which of the following
statements is not true for parameter passing to functions? (a) You can pass positional arguments in any order. (b) You can pass keyword arguments in any order. (c) You can call a function with positional and keyword
arguments. (d) Positional arguments must be before keyword arguments in
a function call. |
1 |
|
2 |
Which of the following function calls can be used to invoke
the below function definition? def test (a, b, c, d) (a) test(1, 2, 3, 4) (c) test(a = 1, b = 2, c = 3, 4) (b) test(a = 1, 2, 3, 4) (d) test(a = 1, b = 2) |
1 |
|
3 |
Which of the following option is the correct Python statement
to read and display the first 10 characters of a text file
"Notes.txt"? (a) F = open('Notes.txt'); print (F.load(10)) (b)F =
open('Notes.txt'); print (F.dump (10)) (c)F = open('Notes.txt'); print (F.read(10)) (d) F = open('Notes.txt'); print (F.write(10)) |
1 |
|
4 |
What is the output produced by following code, if the input
given is : “a” try: x =
float(input("Your number:")) inverse = 1.0/x except ValueError: print ("You should
have given either an int or a float") except ZeroDivisionError: print ("Infinity") finally: print ("There may or
may not have been an exception.") |
1 |
|
5 |
In the following question, a statement of assertion (A) is
followed by a statement of reason (R ). Mark the correct choice as : (a) Both A and R are true and R is the correct explanation of
A. (b) Both A and R are true but R is not the correct
explanation of A. (c) A is true but R is false (or partly true). (d) A is false (or partly true) but R is true. (e) Both A and
R are false or not fully true Assertion. Exception handling code is clear and block based
in Python. Reason. The code where unexpected runtime exception may occur
is separate from the code where the action takes place when an exception occurs |
1 |
|
6 |
Find and write the output of the following python code: def ChangeVal (M,N): for i in range (N): if M[i]%5 == 0: M[i]//= 5 if M[i]%3 == 0: M[i]//= 3 L=[ 25,8,75,12] ChangeVal (L,4) for i in L: print(i, end = '#') |
2 |
|
7 |
Suppose the content of a text file Notes.txt is: "The way to get started is to quit talking and begin doing" What will be the output of the following Python code? F = open("Notes.txt") F.seek(29) S = F.read( ) print(S) |
2 |
|
8 |
What possible outputs(s) are expected to be displayed on
screen at the time of execution of the program from the following code? Also
specify the minimum and maximum values that can be assigned to the variable
End. import random Colours = ["VIOLET", "INDIGO",
"BLUE", "GREEN","YELLOW", "ORANGE",
"RED"] End = random.randint (2)+3 Begin = random.randint (End) +1 for i in range(Begin, End): print (Colours[i],
end="&") (i) INDIGO&BLUE&GREEN& (ii) VIOLET & INDIGO&BLUE& (iii) BLUE&GREEN&YELLOW& (iv) GREEN&YELLOW&ORANGE & |
2 |
|
9 |
Write
a function exchange(L) which will excahnge the positions of maximum and
minimum element of list L |
2 |
|
10 |
A binary file “Book.dat” has structure [BookNo, Book_Name,
Author, Price]. i. Write a user defined function CreateFile() to input data
for a record and add to “Book.dat” . ii. Write a function CountRec(Author) in Python which accepts
the Author name as parameter and count and return number of books by the
given Author are stored in the binary file “Book.dat” |
3 |
|
11 |
Write a
function in python to count the number of lines in a text file ‘STORY.TXT’
which is starting with an alphabet ‘A’ |
3 |
|
12 |
Write a
Python program to read a text file “sample.txt” and copy all the 4 letter
words into another file “temp.txt” |
3 |
|
13 |
i) Differentiate
between seek() and tell() method with an example ii) explain the use of
global keyword in functions with suitable example iii) what is an
exception. Give the examples of any two exceptions with suitable contexts |
3 |
No comments:
Post a Comment