Professional Documents
Culture Documents
Computer ScienceTest
Computer ScienceTest
2
(b) Identify and write the name of the module to which the following functions belong: 1
(i) ceil() (ii) findall()
(c) Observe the following Python code very carefully and rewrite it after removing all 2
syntactical errors with each correction underlined.
DEF execmain() :
x= input(“Enter a number:”)
if (abs(x)=x) :
print “You entered a positive number”
else :
x=*-1
print “Number made positive:” x
execmain()
(d) 2
1
for i in range (len (L1)) :
L2. append (L1[i] + L[i])
L2. append (len (L) – len (L1))
print (L2)
ChangeList ()
(f) Study the following program and select the possible output(s) from the options (i) to (iv) 2
following it. Also, write the maximum and minimum values that can be assigned to the
variable Y.
import random
X=random.random()
Y=random.randint (0, 4)
print (int (X), “:”, Y+int (X))
(i) 0:0
(ii) 1:6
(iii) 2:4
(iv) 0:3
2. (a) 2
(b) Write a Python function if the element in tuple is integer type then display the sum of 2
digits which are multiply by 3 in another tuple .
(c) Write a program using function to swap first half elements with second half element of 2
the list.
3. (a) Observe the following code and answer the questions that follow: 1
File= open (“Mydata”, “a”)
083/3
2
______________________ #Blank1
File.close ()
A. tmpfile.read(n)
B. tmpfile.read()
C. tmpfile.readline()
D. tmpfile.readlines()
f1.seek(10)
print (f1.read(4))
print(f.tell())
f1.seek(5,1)
print (f1.read(4))
print(f.tell())
f1.seek(-5,2)
print(f.tell())
print (f1.read(4))
f1.close()
3
(e) .WAF to read text of 5 line from text1.txt and and delete the 2nd line.
2
(f) WAF count number of alphabets, digits and special characters in text file. 4
4. (a) Which of the following statements correctly explain the function of seek() method? 2
(b) Write read and update binary file record of student using menu drive. Grades written 4
wrong by mistake so update grade to ‘A’ those students whose percentage greater than
90 and ‘B’ in between 80 and 90 rest ‘C’ have format.
[[1,neena,’A’,87],[2,geeta.’b’,93]……..]
(c) Which of the following statements correctly explain the function of tell() method? (1) 1
083/3
4