Professional Documents
Culture Documents
Blueprint
S.NO. NAME OF CHAPTERS TOTAL MARKS VSA(1 SA(2 MARKS) LA(3 MARKS)
MARKS)
1 NETWORKING 5 3 2(4)
2 CYBER SAFETY 1 1
3 FUNCTION 19 4(8) 3(9)
4 RECURSION 8 1(2) 2(6)
5 FILE HANDLING 7 2(4) 1(3)
4 18 18
UNIT TEST- II
CLASS XII
SUBJECT : COMPUTER SCIENCE
4. a) 20
14
(b) 67
69
5. Advantages of using function are:
i. Reusability of code
ii. Makes the program maintenance easy
iii. Improve the readability of program
iv. Reduce design cost /time
6. if local and global variable name are same then global keyword is used to access the global variable
.
x = "global"
deffunc():
global x
print(x)
x = "local"
print(x)
func()
output:-
global
local
7. keyword argument: This allows us to skip arguments or place them out of order because the Python
interpreter is able to use the keywords provided to match the values with parameters.
Ex.
defprintinfo( name, age ):
"This prints a passed info into this function"
print "Name: ", name
print "Age ", age
return;
# Now wecan call printinfo function
printinfo( age=50, name="miki" )
8. program
a) b)
def prime(n): defavg(a):
count=0 sum=0
h=n//2 count=0
for i in range(2,h): for i in a:
if n%i==0: sum=sum+i
count+=1 count+=1
if count==0: average=sum/count
print("prime") print(average)
else: l=[1,2,3,4,8]
print("not prime") avg(l)
R+ W+
Opens a file for both reading and writing. The Opens a file for both writing and reading.
file pointer placed at the beginning of the file. Overwrites the existing file if the file exists. If the
file does not exist, creates a new file for reading
and writing.