Unit Test 1 CSC QP
Unit Test 1 CSC QP
UNIT TEST-I
DATE:8.7.2021 MARKS:25
SECTION A 1X5=5
print(5**4*4**(19-17)//2)
a)def func(a=1,b)
b)def func(a,b=9,c=2)
c)def func(a=1,b=1,c=2)
d)def func(a=1,b=2,c=3,d)
f=open("fruit.txt")
f.seek(3)
print(f.read(7))
SECTION B (2 X3=6)
def funcreams(creams):
del creams[2]
creams[2].remove("NUTS")
creams.pop(3)
print(creams[2][0][0])
cream=["VANNILA","STRAWBERRY","MANGO",["NUTS",["CASHEW","RAIS
INS","ALMONDS"]],"BUTTERSCOTCH","CHOCOLATE"]
funcreams(cream)
print(cream)
7.Write a user defined function privow() to write the lines which are
starting with vowels from the file "alpha.txt" to "vowel.txt"
import random
values=["read","write","append","readandwrite","writeandread"]
n1=random.randint(1,3)
n2=random.randint(2,4)
for i in range(n1,n2+1):
print(values[i],end=" ")
SECTION-C 3 X3=9
def makenew(mystr):
newstr=" "
count=0
for i in mystr:
if count%2==0:
newstr=newstr+i.lower()
else:
if i.islower():
newstr=newstr+i.upper()
else:
newstr=newstr+i
count=count+1
newstr=newstr+mystr[:3]
makenew("St@akis2021")
{"eno":value,"ename":value,"desig":value,"salary":value}
The values for ename and desig are strings and the values for eno and
salary are integers
SECTION D 5x1=5
i) Write a user defined function create() to input data for a record and add
to the file" school.dat"(2)