0% found this document useful (0 votes)
909 views

Unit Test 1 CSC QP

This document contains a unit test for a Computer Science class with 4 sections - A, B, C and D. Section A contains 5 multiple choice questions. Section B contains 3 programming questions. Section C contains 3 questions about writing functions. Section D contains 1 question about writing functions to work with a binary data file. The test covers topics like identifiers, lists, functions, files, and sorting.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
909 views

Unit Test 1 CSC QP

This document contains a unit test for a Computer Science class with 4 sections - A, B, C and D. Section A contains 5 multiple choice questions. Section B contains 3 programming questions. Section C contains 3 questions about writing functions. Section D contains 1 question about writing functions to work with a binary data file. The test covers topics like identifiers, lists, functions, files, and sorting.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

JAIGURUDEV

MAHARISHI VIDYA MANDIR SR.SEC.SCHOOL,CHETPET,CH-31

UNIT TEST-I

CLASS:XII COMPUTER SCIENCE-083 TIME: 1 HR

DATE:8.7.2021 MARKS:25

SECTION A 1X5=5

1. Find the valid identifier(s) from the following:

a)True b)123sum c)none d)_ket12

2. Given the list L1=["hi","unit","test","on",["line",["exam","python"]]]


write the output of print(L1[4][1][1][2])

3.Evaluate the following expression:

print(5**4*4**(19-17)//2)

4. Consider the following function headers.Identify which of these will


cause the error?

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)

5.Consider the following content stored in the file "fruits.txt".Write the


output.

"Deeds are fruits,words are only leaves"

f=open("fruit.txt")

f.seek(3)

print(f.read(7))

SECTION B (2 X3=6)

6.Find the output of the following program

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"

8.What possible output(s) are expected to displayed on screen at the time


of execution of the program from the following code?

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=" ")

a)append b)append readandwrite c) read d) write append

SECTION-C 3 X3=9

9.Write the output for the following code:

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]

print("the new string is:",newstr)

makenew("St@akis2021")

10.Following is the structure of each record in a data file named


"employee.dat"

{"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

Write a function in Python to delete the record those employee's salary is


lesser than 30000

11.Write a function in Python to print the list of strings in descending


order using insertion sort method

SECTION D 5x1=5

12a).A binary file "school.dat" has a structure [Teacherid,Tname,Dept,


Experience]

i) Write a user defined function create() to input data for a record and add
to the file" school.dat"(2)

ii)Write a function countrec(dept)in Python which accepts the department


name as parameter and count and return no.of.teachers who have
working in the department stored in binary file "school.dat(3)

****** ALL THE BEST******

You might also like