oldpapers
oldpapers
9. To increase the value of k five times using an assignment operator, the correct
expression will be :
k += 5 B) k *=5 C) k = k**5 D) k =*5
10. What is the value of x ?
x = int (13.25 +4/2)
a) 17 b) 14 c) 15 d) 23
11. What will be the output of the following code:-
x = 73
y = x%9
print(y)
12. The statement forms the selection construct in Python.
A) for B) while C) if D) None
13. Suppose t = (1, 2, 4, 3), which of the following is incorrect?
a) print(t[3]) b) t[3] = 45 c) print(max(t)) d) print(len(t))
1
14. Identify the type of error
a=10 , b=0
c=a/b
i) Semantics Error ii) Syntax Error iii) Run Time error iv )No Error
15. A loop becomes an infinite loop if a condition never becomes true.
a. True b. False
16. What is the output of following code :
L = [ 5, 8]
print (L * 3)
a) Syntax error b) [5,8,5,8,5,8] c) [15,24] d) [8,11]
17 Which of the following will delete key-value pair for key = “Red” from a
dictionary D1?
a. delete D1("Red") b. del D1["Red"] c. del.D1["Red"] d. D1.del["Red"]
18 Which of the following is a function of the math Module?
a. random() b) mean() c) floor() d) median()
19 Which of the following outputs is the correct option for the code shown here ?
STR='TEXT CONTENT'
print(STR.strip('T'))
a. EX CONEN b) EX CONTEN c) EXT CONTEN d) TEXT CONTEN
Q20 and Q21 are Assertion(A) and Reason(R) based questions. Mark
the correct choice as:
(A)Both A and R are true and R is the correct explanation for A
(B)Both A and R are true and R is not the correct explanation for A
(C)A is True but R is False
(D)A is False but R is True
20 Assertion(A): List is an immutable data type
Reasoning(R): When an attempt is made to update the value of an immutable variable,
the old variable is destroyed and a new variable is created by the same name in
memory.
21 Assertion (A):- The expression sorted('TEXT')in Python will give Error.
Reasoning (R):- String is an immutable type in Python.
SECTION – B (7 X 2 =14)
22 Rewrite the following code after removing all the syntax errors with each of the
corrections underlined:
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else
print("Number is prime \n’)
23 Write the results of the following:
a. print(6 * 15 - 2 // 7 - 2 * 3)
b. print(12 * 3 + 43 - 2 + 5 % 2)
24 Draw a logic circuit equivalent for the following Boolean Expression:
A’ + B’ + C’
OR
2
Draw a logic circuit equivalent for the following Boolean Expression:
(A’.B’)+ C’
25 Write the output of the Python code given below:
wD=('SUN','MON','TUE','WED','THU','FRI','SAT')
L=D[1:len(D)-1]
print('#'.join(L))
OR
Write the output of the Python code given below:
D={'Grapes':50,'Mango':70,'Banana':20}
print(sorted(D))
26 Give two examples of each of the following:
(I) Arithmetic operators (II) Relational operators
27 Expand the following : a) ASCII b) ZB
28 Differentiate between mutable and immutable data type.
SECTION – C (3 X 3 =9
29 Write a program to check whether an integer number input by a user is prime or not?
OR
Write a program to input an integer value and display it in reverse order
30 What do you mean by data types? Explain different datatypes available in python with
examples.
Or
What are comments? What is the use of comments in programming?
31 Consider the following code segment for the questions A to E:
a=int(input("enter an integer"))
b=int(input("enter an integer"))
if a<=0:
b=b+1
else:
a=a+1
if a>0 and b>0:
print("W")
elif a>0:
print("X")
if b>0:
print("Y")
else:
print("Z")
A. What letters will be printed if the user enters 0 for a and 0 for b?
a. Only W b). Only X c). Only Y d) W and X e) W,X and Y
3
B. What letters will be printed if the user enters 1 for a and 1 for b?
a. W and X b). W and Y c). X and Y d). X and Z e). W,X and Y
C. What letters will be printed if the user enters 1 for a and -1 for b?
a. W and X b). X and Y c). Y and Z d). X and Z e). W and Z
D. What letters will be printed if the user enters 1 for a and 0 for b?
a. W and X b). X and Y c). Y and Z d). X andZ e). W and Z
E. What letters will be printed if the user enters -1 for a and -1 for b?
a. Only W b) Only X c) Only Y d) Only Z e) No letters are printed
F. What letters will be printed if the user enters 0 for a and 1 for b?
a. Only W b) Only X c) Only Y d) Only Z e) No letters are printed
SECTION – D (4 X 4 = 16)
32
Write single line Python commands to perform each of the following operations:
QUOTE="Life is beautiful"
● Display the length of the string QUOTE.
● Display the reverse of the string QUOTE.
● Display the count of 'i' from the string QUOTE
● Display the substring 'beauti'from the string QUOTE.
Or
Write a python code to accept values of X as float and N as int, find and display the
sum of following series:
(a) 1 + 4 + 7 + ... upto N
1/X1 + 1/X2+ 1/X3... upto Nth Terms
33 Write a Python code to accept a number and display its factors. The process should
continue till the user wants.
For Example
Enter N: 10
Factors: 1,2,5,10
34 Give 2 example for each of the following :
a) Hardware b) Software c) output devices d) input devices
35 List the function of operating system and explain.
SECTION – E (2X5=10)
36 Convert the following from one number system to another ( show the complete working )
:
a. (512)10 =( )2
b. (10010111)2 =( )10
c. (451)8 =( )16
d. (111001101)2 = ( )8
e. (175)10= ( )8
37 Explain the following dictionary functions with example :
setdefault()
fromkeys()
keys()
4
5
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL, CHENNAI - 39
Std :XI PRE-ANNUAL EXAMINATION – 2024-25 Time : 3 Hrs
Subject : Computer Science SET - 2 Max. Marks:70
General Instructions:
● This question paper contains 37 questions.
● All questions are compulsory. However, internal choices have been provided in some
questions. Attempt only one of the choices in such questions
● The paper is divided into 5 Sections- A, B, C, D and E.
● Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
● Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
● Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
● Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
● Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
● All programming questions are to be answered using Python Language only.
● In case of MCQ, text of the correct answer should also be written.
9. To increase the value of k five times using an assignment operator, the correct
expression will be :
k += 5 B) k *=5 C) k = k**5 D) k =*5
10. What is the value of
x ? x = int (13.25
+4/2)
a) 17 b) 14 c) 15 d) 23
11. A loop becomes an infinite loop if a condition never becomes true.
a. True b. False
12. The statement forms the selection construct in Python.
A) for B) while C) if D) None
13. Suppose t = (1, 2, 4, 3), which of the following is incorrect?
a) print(t[3]) b) t[3] = 45 c) print(max(t)) d) print(len(t))
6
14. Identify the type of error
a=10 , b=0
c=a/b
i) Semantics Error ii) Syntax Error
iii) Run Time error iv )No Error
15. What will be the output of the following code:-
x = 73
y = x%9
print(y)
16. What is the output of following code :
L = [ 5, 8]
print (L * 3)
b) Syntax error b) [5,8,5,8,5,8] c) [15,24] d) [8,11]
17 Which of the following will delete key-value pair for key = “Red” from a
dictionary D1?
a. delete D1("Red") b. del D1["Red"] c. del.D1["Red"] d. D1.del["Red"]
18 Which of the following is a function of the math Module?
b. random() b) mean() c) floor() d) median()
19 Which of the following outputs is the correct option for the code shown here ?
STR='TEXT CONTENT'
print(STR.strip('T'))
b. EX CONEN b) EX CONTEN c) EXT CONTEN d) TEXT CONTEN
Q20 and Q21 are Assertion(A) and Reason(R) based questions. Mark
the correct choice as:
(A)Both A and R are true and R is the correct explanation for A
(B)Both A and R are true and R is not the correct explanation for A
(C)A is True but R is False
(D)A is False but R is True
20 Assertion(A): List is an immutable data type
Reasoning(R): When an attempt is made to update the value of an immutable
variable, the old variable is destroyed and a new variable is created by the same
name in memory.
21 Assertion (A):- The expression sorted('TEXT')in Python will give Error.
Reasoning (R):- String is an immutable type in Python.
SECTION – B (7 X 2 =14)
22 Rewrite the following code after removing all the syntax errors with each of the
corrections underlined:
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else
print("Number is prime \n’)
23 Write the results of the following:
a) print(6 * 15 - 2 // 7 - 2 * 3) b) print(12 * 3 + 43 - 2 + 5 % 2)
24 Draw a logic circuit equivalent for the following Boolean Expression: A’ + B’ + C’
7
OR
Draw a logic circuit equivalent for the following Boolean Expression: (A’.B’)+ C’
25 Write the output of the Python code given below:
D=('SUN','MON','TUE','WED','THU','FRI','SAT') L=D[1:len(D)-1]
print('#'.join(L))
OR
Write the output of the Python code given below:
D={'Grapes':50,'Mango':70,'Banana':20}
print(sorted(D))
26 Give two examples of each of the following:
(I) Arithmetic operators (II) Relational operators
27 Expand the following : a) ASCII b) ZB
28 Differentiate between mutable and immutable data type.
SECTION – C (3 X 3 =9
29 Write a program to check whether an integer number input by a user is prime or not?
OR
Write a program to input an integer value and display it in reverse order
30 What do you mean by data types? Explain different datatypes available in python
with examples.
Or
What are comments? What is the use of comments in programming?
31 Consider the following code segment for the questions A to E:
a=int(input("enter an integer"))
b=int(input("enter an integer"))
if a<=0:
b=b+1
else:
a=a+1
if a>0 and b>0:
print("W")
elif a>0:
print("X")
if b>0:
print("Y")
else:
print("Z")
A. What letters will be printed if the user enters 0 for a and 0 for b?
a. Only W b). Only X c). Only Y d) W and X e) W,X and Y
B. What letters will be printed if the user enters 1 for a and 1 for b?
a. W and X b). W and Y c). X and Y d). X and Z e). W,X and Y
8
C. What letters will be printed if the user enters 1 for a and -1 for b?
a. W and X b). X and Y c). Y and Z d). X and Z e). W and Z
D. What letters will be printed if the user enters 1 for a and 0 for b?
a. W and X b). X and Y c). Y and Z d). X andZ e). W and Z
E. What letters will be printed if the user enters -1 for a and -1 for b?
a. Only W b) Only X c) Only Y d) Only Z e) No letters are printed
F. What letters will be printed if the user enters 0 for a and 1 for b?
a. Only W b) Only X c) Only Y d) Only Z e) No letters are printed
SECTION – D (4 X 4 = 16)
32
Write single line Python commands to perform each of the following operations:
QUOTE="Life is beautiful"
● Display the length of the string QUOTE.
● Display the reverse of the string QUOTE.
● Display the count of 'i'from the string QUOTE
● Display the substring 'beauti'from the string QUOTE.
Or
Write a python code to accept values of X as float and N as int, find and display the
sum of following series:
(a) 1 + 4 + 7 + ... upto N
(b) 1/X1 + 1/X2+ 1/X3... upto Nth Terms
33
Write a Python code to
● Input 10 integers into a list NUM.
● Display all the multiple of 5 from the list NUM
● Display the highest and lowest integer from the list NUM
● Display the list NUM in the ascending order.
34 Define the following terms:
a) Application Software b) Compiler c) Interpreter d) System Utilities
35 State and prove Demorgan’s law using Truth table.
SECTION – E (2X5=10)
36 Convert the following from one number system to another ( show the complete
working ) :
a. (512)10 =( )2
b. (10010111)2 =( )10
c. (451)8 =( )16
d. (111001101)2 = ( )8
e. (175)10= ( )8
37 Explain the following dictionary functions with example :
get()
popitem()
update()
9
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL, CHENNAI - 39
Std :XI II MID TERM – 2024-25 Time : 3 Hrs
Subject : Computer Science SET - 1 Max. Marks:70
General Instructions:
This question paper contains five sections, Section A to E.
1. All questions are compulsory.
2. Section A have 18 questions carrying 01 mark each.
3. Section B has 07 Very Short Answer type questions carrying 02 marks each.
4. Section C has 05 Short Answer type questions carrying 03 marks each.
5. Section D has 02 Long Answer type questions carrying 04 marks each.
6. Section E has 03 Very Long Answer type questions carrying 05 marks each.
Q No. Questions Section-A (18 Marks) Marks
1 Which symbol is used to represent processing in flowcharts. 1
a) circle b) rectangle c) diamond d) parallelogram
2 Which of the following is not a token 1
a) keyword b) identifier c) expression d) operator
3 What will be the output of the following statement: 1
print(4+2**3**2-5//11%3)
a) 66 b) 46 c) 516 d) 494
4 What is the output of the following code 1
print(str([1,2,3]))
a) ‘123’ b) ‘1,2,3’ c) ‘[1,2,3]’ d) error
5 State True or False: 1
“In a Python program if break statement is executed in a loop then loop’s
else block will be executed or not”.
6 Which gate produces 1 when all inputs are 1. 1
a) NAND b) NOT c) AND d) OR
7 Which of the following expression will result in an error 1
a) ‘3’ * 3 b) (3) * 3 c) [3] * 3 d) ‘3’+7
8 Which of the following is / are tuple? 1
a) 3,5 b) (10) c) (15,16) d) [1,2, (3,4)]
9 Which of the following statement(s) would give an error during execution 1
of the
following code?
s = ‘Python supremacy’
print(s) #Statement 1
print(s[0]+ ‘O’ ) #Statement 2
s[0] = ‘p’ #Statement 3
print(max(s)) #Statement 4
a) Statement 1 b) Statement 2 c) Statement 3 d) Statement 4
10
10 Which one of the following in correct ascending order of size for nibble, 1
byte, kb, bit, mb
a) bit<byte<nibble<mb<kb b) nibble<byte<bit<kb<mb
c) bit<byte<nibble<kb<mb d) bit<nibble<byte<kb<mb
11 ____________________is a system software that translates and executes 1
instructions
written in a computer program line-by-line.
a) Assembler b) Interpreter c) Compiler d) None of these
12 Which encoding scheme has code points for all the known languages 1
a) ASCII b) Unicode c) ISCII d) none of these
13 The hexadecimal digits are 1 to 0 and A to ________________
a) E b). F c). G d). D
14 Which of the following is an escape sequence for a new line character?
a) \a b). \t c) \n d) \b
15 Mr Somil assigned the values to python variable, What will the following
code produce?
A , B = 8.6
print(A//B)
a)4.3 b). 4.0 c). 4 d) Compilation error
16 Which of the following will return the last element of a list L with 5
elements?
a. L[5] b) L[-4] c) L[-1] d) L[6]
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the
correct choice as
a. Both A and R are true and R is the correct explanation for A
b. Both A and R are true and R is not the correct explanation for A
c. A is True but R is False
d. A is false but R is True
17 if 7:
print(“True”)
else:
print(“False”)
Assertion (A): Output of the above code is False
Reasoning (R): Non-empty and Non-Zero object is treated as True.
18 d={1,11,[2,22], 3,33]
print(2 in d)
Assertion (A): Output of above code is False.
Reasoning (R): Membership operator does not check for values in the
nested sequence.
Q No. Questions Section-B (14 Marks) Marks
19 What is the difference between RAM and ROM? 2
Or
Name the input or output device to do the following :
a. To output audio b. To enter textual data c. To make hard copy of a
11
text file.
d. To display the data or information
12
24 If value = (5,4,3,2,1,0) evaluate the following expressions: 2
print(value[0])
print (value[value[0]])
print(value[value[-2]])
print(value[value[value[value[2]+1]]])
25 Write logical expression for the following: 2
1) Name is riya and age is between 10 and 15
2) CITY is either ‘Delhi’ or ‘Mumbai’ but not ‘Kolkata’
13
32 Write a program to input names of n students and store them in a tuple. 4
Also, input a name from the user and find if this student is present in the
tuple or not.
Q No. Questions Section-E (15 Marks) Marks
33 Explain any 5 string functions with example 5
14
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL, CHENNAI - 39
Std :XI II MID TERM – 2024-25 Time : 3 Hrs
Subject : Computer Science SET - 2 Max. Marks:70
General Instructions:
This question paper contains five sections, Section A to E.
1. All questions are compulsory.
2. Section A have 18 questions carrying 01 mark each.
3. Section B has 07 Very Short Answer type questions carrying 02 marks each.
4. Section C has 05 Short Answer type questions carrying 03 marks each.
5. Section D has 02 Long Answer type questions carrying 04 marks each.
6. Section E has 03 Very Long Answer type questions carrying 05 marks each.
Q No. Questions Section-A (18 Marks) Marks
1 Which of the following will create a single element tuple? 1
a. (1,) b) (1) c) ([1]) d) None of these
2 Dictionaries are also called_____ 1
a. Mappings b) Hashes c) Associative arrays d) All of these
3 Ms. Asha develop program of application of operator but she was 1
confused amongst the operator available, Suggest her Which of the
following is/are not legal string operators?
a)in b) + c) * d) /
4 An input function always returns a value of ___________ type. 1
5 A variable can contain values of different types at different times. 1
(True/False)
6 What will be the value of y after following code fragment is executed? 1
x=10.0
y=(x<100.0) and x>=10
(a)110 (b)True (c)False (d)Error
7 Which loop is appropriate to use when the number of iterations is 1
known?
A. for loop B. while loop C. do-while loop D. break loop
8 How can you check if a string contains only alphabets? 1
a) isalpha() b) isalphabet() c) isletters() d) isalphabets()
9 What is the output of the following code? 1
y = (3)
print(type(y))
a) <class ‘int’> b) <class ‘tuple’> c) <class ‘list’> d) <class str>
10 The Physical components of computer are called 1
a. Hardware b. Software c. Firmware d. CPU
15
11 Consider the given expression: not True and False or True 1
Which of the following will be correct output if the given expression is
evaluated?
(a) True (b) False (c) NONE (d) NULL
12 Identify the valid relational operator(s) in Python from the following : 1
(A) = (B) < (C) <> (D) not
13 What will the following expression be evaluated to in Python?
print(15.0 / 4 + (8 + 3.0))
(a) 14.75 (b)14.0 (c) 15 (d) 15.5
14 Which of the following is an invalid statement?
a) a=b=c=2 b) a,b,c=10,20,30 c) a b c=20,30,40 d) a_b_c=20
15 What is the output of the following code?
str1= “Mission 999”
str2= “999”
print(str1.isdigit(), str2.isdigit())
a. False True b. False False c. True False d. True True
16 Which symbol is used to represent input/output in flowcharts.
a) circle b) rectangle c) diamond d) parallelogram
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the
correct choice as
a. Both A and R are true and R is the correct explanation for A
b. Both A and R are true and R is not the correct explanation for A
c. A is True but R is False
d. A is false but R is True
17 Assertion (A): Strings in Python are mutable.
Reason (R): The first character has the index 0 and the last character has
the index n-1 where n is the length of the string.
18 Assertion: The ‘for’ loop is a counting loop that works with sequences of
values.
Reason: The range() function generates a sequence of list type
Q No. Questions Section-B (14 Marks) Marks
19 What is the difference between RAM and ROM? 2
Or
Name the input or output device to do the following :
a. To output audio
b. To enter textual data
c. To make hard copy of a text file.
d. To display the data or information
20 Write a program to input two numbers and swap them. 2
Or
Write a program to input a number and print its cube and also print
original number.
16
21 What does each of the following expressions evaluates to? Suppose that 2
L is the list
[“These”, [“are”, “a”], [“few”, “words”], “that”, “we”, “will”, “use”]
a. len( L )
b. L[3 : 4] + L[1 : 2]
or
a)What is the output produced when this code executes?
A=0
for I in range (4, 8):
if I % 2 = = 0:
A=A+I
print (A)
b)How many times does the following code execute?
X=1
while ( X < = 5):
X+1
print(X)
22 Draw logic circuit for following Boolean expressions: 2
(i) AB’ + B(A+C)
(ii) (AB+BC)(AC)
23 Correct and rewrite the following code underlining all the corrections. 2
x=int(input(“Enter speed”)
if x>120
print(“Vehicle impounded”)
else x=>80:
print(“Fine 2000 Rs.)
else:
print(“Good to go”)
OR
Write output of the following code:
x=1531
s=0
while x>0:
a=x%10
s=s+a
x=x//10
print(s)
24 If value = (5,4,3,2,1,0) evaluate the following expressions: 2
print(value[0])
print (value[value[0]])
print(value[value[-2]])
print(value[value[value[value[2]+1]]])
25 Write logical expression for the following: 2
1) Name is riya and age is between 10 and 15
2) CITY is either ‘Delhi’ or ‘Mumbai’ but not ‘Kolkata’
17
Q No Questions Section-C (15 Marks) Marks
26 Write a program to generate the following series using loop structure to 3
generate upto n terms.
123 A
12 or AB
1 ABC
27 Write a Python program to calculate bonus as the following criteria using 3
if- elif statement :
If salary between bonus
Salary - 0 to 25000 Bonus - 25% of salary
Salary - 25001 to 35000 Bonus - 15% of salary
Salary - 35001 to 50000 Bonus - 10% of salary
Salary - 50001 to 75000 Bonus - 05 % of salary
Salary - 75001 and above Bonus - nil
28 Find the output of the following code: 3
>>> L=["These", "are", "a", ["few", "words"], "that", "we", "will", "use"]
>>> print (L[3:4])
>>> print (L[1:4:-1])
>>> print ("few" in L)
>>> print (L[0::2])
>>> print (L[4:])
>>> print (L)
29 State De Morgan’s laws / theorems and prove using truth table. 3
30 What is indexing and which data type supports indexing explain with 3
example.
Q No. Questions Section-D (8 Marks) Marks
31 Convert the following number system. 4
(a) (11011.10 )2 into ()10
(b)(11100.1010)2 in to ()16
(c) (10AF)16 into ()2
(d)(A42)16 into ()8
32 Write a program to input names of n students and store them in a tuple. 4
Also, input a name from the user and find if this student is present in the
tuple or not.
Q No. Questions Section-E (15 Marks) Marks
33 Explain any 5 string functions with example 5
18
19
20
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL, CHENNAI - 39
Std :XII II MID TERM – 2024-25 Time : 3 Hrs
Subject : Computer Science SET - 1 Max. Marks:70
General Instructions:
This question paper contains five sections, Section A to E.
1. All questions are compulsory.
2. Section A have 18 questions carrying 01 mark each.
3. Section B has 07 Very Short Answer type questions carrying 02 marks each.
4. Section C has 05 Short Answer type questions carrying 03 marks each.
5. Section D has 02 Long Answer type questions carrying 04 marks each.
6. Section E has 03 Very Long Answer type questions carrying 05 marks each.
Q No. Questions Section-A (18 Marks) Marks
1 Which of the following is an invalid identifier to be used in Python? 1
a. per%marks b) _for c) While d) true
2 What is the correct way to add an element to the end of a list in Python? 1
a. list.add(element) b) list.append(element) c) list.insert(element)
d) list.extend(element)
3 What will be the output of 1
print("Welcome To My Blog"[2:6] + "Welcome To My Blog"[5:9])
a. Lcomme b) lcomme T c) lcomme To d) lcomme
4 Which of the following statements is false? 1
a. A try-except block can have more than one except statement
b. One block of except statement cannot handle multiple exceptions
c. The finally block is always executed
d. When 1 == "1" is executed, no exception is raised
5 Which of the following statement(s) would give an error during the 1
execution of the following code?
R = {'pno':52,'pname':'Virat', 'expert':['Badminton','Tennis']
,'score':(77,44)} print(R) #Statement 1
R['expert'][0]='Cricket' #Statement 2
R['score'][0]=50 #Statement 3
R['pno']=50 #Statement 4
a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4
6 Which pickle module method is used to write a Python object to a binary 1
file?
a. save() b) serialize() c) store() d) dump()
21
7 Given the following dictionaries 1
dict_student = {"rno" : "53", "name" : 'Rajveer
Singh'}
dict_marks = {"Accts" : 87, "English" : 65}
22
16 Fill in the blank: 1
_________ protocol provides access to services hosted on a remote
computer.
23
The output should be:
PYTHON NETWORKING
21 OR 2
Write a Python Program containing a function FindWord(STRING,
SEARCH), that accepts two arguments : STRING and SEARCH, and prints
the count of occurrence of SEARCH in STRING. Write appropriate
statements to call the function.
L = [5,10,15,1] G =
4 def Change(X):
global G
N=len(X) for i
in range(N):
X[i] += G
Change(L)
for i in L:
print(i,end='$')
23 Write a suitable Python statement for each of the following tasks using 2
built-in functions/methods only:
i To delete an element Mumbai:50 from Dictionary D. ii To
display words in a string S in the form of a list
OR
Write a Python Program to display alternate characters of a string
my_str.
For example, if my_str = "Computer Science"
The output should be Cmue cec
24 Differentiate between % (percentage) and _(underscore) characters used 2
with the LIKE operator in SQL with appropriate examples.
OR
Differentiate between DROP and DELETE commands in SQL with
appropriate examples.
24
25 Consider the following two commands with reference to a table, named 2
Employee having a column named Department:
(a) Select count(Department) from Employee;
(b) Select count(*) from Employee;
TABLE : BOOK
CODE BNAME TYPE
F101 The priest Fiction
L102 Easy Python Programming
C101 Juman Ji Thriller
F102 Untold Story Fiction
C102 War Stories Comic
Table: MEMBER
MNO MNAME CODE ISSUEDATE
M101 SNEH SINHA L102 2022-10-13
M103 SARTHAK F102 2021-02-23
M102 SARA KHAN C101 2022-06-12
What will be the output of the following statement?
SELECT * FROM BOOK NATURAL JOIN MEMBER;
26 (b) Write the output of the queries (i) to (iv) based on the table 3
Table: Employee
EID Name DOB DOJ Salary Project
E01 Ranjan 1990-07-12 2015-01-21 150000 P01
E02 Akhtar 1992-06-21 2015-02-01 125000 P04
E03 Muneera 1996-11-15 2018-08-19 135000 P01
E04 Alex 1991-10-25 2018-10-19 75000 P02
E05 Satyansh 1993-12-16 2018-10-19 85000 P04
i SELECT NAME, PROJECT FROM EMPLOYEE ORDER BY NAME
DESC;
ii SELECT NAME, SALARY FROM EMPLOYEE WHERE NAME LIKE
'A%';
iii SELECT NAME, DOJ FROM EMPLOYEE WHERE SALARY
BETWEEN 100000 AND 200000;
25
iv SELECT * FROM EMPLOYEE WHERE PROJECT = 'P01';
27 Table: COURSES 3
C_ID FID CNAME FEES
C11 F01 Grid Computing 40000
C12 F04 Python 17000
C13 F03 C++ 8000
C14 F04 Computer Network 15000
C15 F01 HTML 12000
C16 F05 Data Science NULL
What will be the output of the following statement?
i SELECT FID, MIN(FEES), MAX(FEES) FROM COURSES GROUP BY FID;
ii SELECT AVG(SALARY) FROM FACULTY WHERE FNAME LIKE '%a';
iii SELECT FNAME, CNAME FROM FACULTY F, COURSES C WHERE
F.FID=C.FID AND COURSES.FID='F04';
iv SELECT FNAME, CNAME , FEES FROM FACULTY F , COURSES C WHERE
F.FID = C.FID AND FEE>15000;
26
28 Write a function COUNT() in Python to read from a text file
'Gratitude.txt' and display the count of the letter 'e' in each line
Example: If the file content is as follows:
Gratitude is a humble heart's radiant glow, A
timeless gift that nurtures and bestows. It's
the appreciation for the love we're shown, In
moments big and small, it's truly known.
The COUNT() function should display the output as:
Line 1 : 3
Line 2 : 4
Line 3 : 6
Line 4 : 1
OR
Write a function Start_with_I() in Python, which should read a text
file 'Gratitude.txt'(as given above) and then display lines starting
with 'I'.
27
30 Given a Dictionary Stu_dict containing marks of students for three
test-series in the form Stu_ID:(TS1, TS2, TS3) as key-value pairs. Write a
Python program with the following user-defined functions to perform
the specified operations on a stack named Stu_Stk
(i) Push_elements(Stu_Stk, Stu_dict) : It allows pushing
IDs of those students, from the dictionary Stu_dict into the stack
Stu_Stk, who have scored more than or equal to 80 marks in the TS3
Test.
(ii) Pop_elements(Stu_Stk): It removes all elements present
inside the stack in LIFO order and prints them. Also, the function displays
'Stack Empty' when there are no elements in the stack. Call both
functions to execute queries.
For example:
If the dictionary Stu_dict contains the following data:
Stu_dict ={5:(87,68,89), 10:(57,54,61), 12:(71,67,90),
14:(66,81,80), 18:(80,48,91)}
28
32 Consider a binary file 'INVENTORY.DAT' that stores information about 4
products using tuple with the structure (ProductID, ProductName,
Quantity, Price). Write a Python function
expensiveProducts() to read the contents of
'INVENTORY.DAT' and display details of products with a price higher
than Rs. 1000. Additionally, calculate and display the total count of such
expensive products.
For example: If the file stores the following data in binary format
(1, 'ABC', 100, 5000)
(2, 'DEF', 250, 1000) (3,
'GHI', 300, 2000)
then the function should display
Product ID: 1
Product ID: 3
Total expensive products: 2
Q No. Questions Section-E (15 Marks) Marks
33 Fun Media Services Ltd is an event planning organization. It is planning
to set up its India campus in Mumbai with its head office in Delhi. The
Mumbai campus will have four blocks/buildings - ADMIN, DECORATORS,
FOOD, and MEDIA.
You as a network expert need to suggest the best network-related
solutions for them to resolve the issues/problems mentioned in points
(i) to (v), keeping in mind the distances between various
blocks/buildings and other given parameters.
29
The number of computers at various buildings is as follows:
BUILDING NUMBER OF
COMPUTERS
ADMIN 110
DECORATORS 75
MEDIA 12
FOOD 20
i) Suggest the most appropriate location of the server inside the
MUMBAI campus (out of the 4 buildings). Justify your answer.
ii) Draw the cable layout to efficiently connect various buildings within
the MUMBAI campus. iii. Which hardware device will you suggest to
connect all the computers within each building?
Iii) Which of the following will you suggest to establish online face-to-
face communication between the people in the Admin Office of the
MUMBAI campus and the DELHI Head Office?
a. Cable TV b) Email c) Video Conferencing d) Text Chat
Iv) What type of network (out of PAN, LAN, MAN, WAN) will be set up in
each of the following cases?
a. The Mumbai campus gets connected with the Head Quarter in
Delhi
b. The computers connected in the MUMBAI campus
34 i) Mention any two differences between seek() and tell().
ii) Consider a file FLIGHT.DAT containing multiple records. The structure
of each record is as shown below:
[Fno, FName, Fare, Source, Destination]
Write a function COPY_REC() in Python that copies all those records
from FLIGHT.DAT where the source is DELHI and the
destination is MUMBAI, into a new file RECORD.DAT
OR
34 i) Mention any two differences between binary files and csv files? 2+3=5
ii) Consider a Binary file BOOK.DAT containing a dictionary having
multiple elements. Each element is in the form
BNO:[BNAME,BTYPE,PRICE] as key:value pair where
BNO – Book Number
BNAME – Book Name
BTYPE - Book Type
PRICE – Book price
Write a user-defined function, findBook(price), that accepts price as
parameter and displays all those records from the binary file BOOK.DAT
which has a book price more than or equal to the price value passed as a
parameter.
30
35 i. Define the term constraint with respect to RDBMS. Give a suitable
example.
ii. Sameera maintains a database named STORE which contains a
table named ITEM with the structure given below:
• Ino(Item number )- integer
• Iname(Item Name) – string
• Price (Item Price) – float
• Discount (Discount) – float
Note the following to establish connectivity between Python and
MySQL:
• Username - root
• Password - tiger
• Host - localhost
Write a python code with mysql connectivity to remove the record from
the table ITEM for a particular value of item name input by the user.
OR
i. Write one difference between the alternate key and the candidate
key.
ii. A table named ITEM is created in a database STORE. The table
contains multiple columns whose details are as shown below:
• Ino(Item number )- integer
• Iname(Item Name) – string
• Price (Item Price) – float
• Discount (Discount) – float
Note the following to establish connectivity between Python and MySQL:
• Username - root
• Password - tiger
• Host - localhost
Write a python code with mysql connectivity to run the query to display
details of all such items from the table ITEMS whose price is more than
5000.
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL, CHENNAI - 39
Std :XII II MID TERM – 2024-25 Time : 3 Hrs
Subject : Computer Science SET - 2 Max. Marks:70
General Instructions:
This question paper contains five sections, Section A to E.
7. All questions are compulsory.
8. Section A have 18 questions carrying 01 mark each.
9. Section B has 07 Very Short Answer type questions carrying 02 marks each.
10. Section C has 05 Short Answer type questions carrying 03 marks each.
11. Section D has 02 Long Answer type questions carrying 04 marks each.
31
12. Section E has 03 questions carrying 04 marks each.
6 6. ‘L’ in HTML stands for : 1
(A) Large (b) Long (c) Language (D) Laser
7 Identify the valid Python identifier from the following : 1
(A) 2user (b) user 2 (c) user@2 (D) user 2
8 Consider the statements given below and then choose the correct output 1
from the given options 1
Game="World Cup 2023"
print(Game[-6::-1])
(A) CdrH (b) puC dlroW (c) ce o (D) Error
32
11 11. Ethernet card is also known as : 1 1
(A) LIC (b) NIC (c) MIC (d) OIC
12 What will be the output of the given code ? 1 1
a=10
def convert(b=20):
a=30
c=a+b
print(a,c)
convert(30)
print(a)
13 For the following Python statement : 1 1
N = (25)
What shall be the type of N ?
(A) Integer (B) String (C) Tuple (D) List
14 Mr. Ravi is creating a field that contains alphanumeric values and fixed 1
lengths. Which MySQL data type should he choose for the same ?
(A) VARCHAR b) CHAR c) LONG d) NUMBER
15 Fill in the blank : 1 1
The full form of WWW is
16 ______files are stored in a computer in a sequence of bytes. 1 1
a) Text b) Binary (c) csv (D) Notepad
Q17 and 18 are ASSERTION AND REASONING based questions.
Mark the correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17 Assertion (A) : Global variables are accessible in the whole program. 1
Reason (R) : Local variables are accessible only within a function or block
in which it is declared.
18 Assertion (A) : If numeric data are to be written to a text file, the 1
data needs to be converted into a string before writing to the file.
Reason (R) : write() method takes a string as an argument and writes it
to the text file.
Q No. Questions Section-B (14 Marks) Marks
19 Write two advantages and two disadvantages of circuit switching. 2
OR
Differentiate between Web server and web browser. Write the names of
any two web browsers.
33
20 Rewrite the following code in Python after removing all the syntax errors. 2
Underline each correction done in the code.
num1, num2 = 10, 45
While num1 % num2 ==
0 num1+= 20 num2+=
30
Else:
print('hello')
21 Write a function dispBook(BOOKS) in Python, that takes a dictionary
BOOKS as an argument and displays the names in uppercase of those
books whose name starts with a consonant.
L = [5,10,15,1] G =
4 def Change(X):
global G
N=len(X) for i
in range(N):
X[i] += G
Change(L)
for i in L:
print(i,end='$')
34
23 Write a suitable Python statement for each of the following tasks using 2
built-in functions/methods only:
i To delete an element Mumbai:50 from Dictionary D. ii To
display words in a string S in the form of a list
OR
Write a Python Program to display alternate characters of a string
my_str.
For example, if my_str = "Computer Science"
The output should be Cmue cec
24 Differentiate between % (percentage) and _(underscore) characters used 2
with the LIKE operator in SQL with appropriate examples.
OR
Differentiate between DROP and DELETE commands in SQL with
appropriate examples.
25 Consider the following two commands with reference to a table, named 2
Employee having a column named Department:
(a) Select count(Department) from Employee;
(b) Select count(*) from Employee;
35
26 (a) Write the output of the queries (i) to (iv) based on the table 3
Table: Employee
EID Name DOB DOJ Salary Project
E01 Ranjan 1990-07-12 2015-01-21 150000 P01
E02 Akhtar 1992-06-21 2015-02-01 125000 P04
E03 Muneera 1996-11-15 2018-08-19 135000 P01
E04 Alex 1991-10-25 2018-10-19 75000 P02
E05 Satyansh 1993-12-16 2018-10-19 85000 P04
i SELECT NAME, PROJECT FROM EMPLOYEE ORDER BY NAME
DESC;
ii SELECT NAME, SALARY FROM EMPLOYEE WHERE NAME LIKE
'A%';
iii SELECT NAME, DOJ FROM EMPLOYEE WHERE SALARY
BETWEEN 100000 AND 200000;
iv SELECT * FROM EMPLOYEE WHERE PROJECT = 'P01';
27 (a) Consider the following tables – FACULTY and COURSES :
Table: FACULTY
FID FNAME LNAME JOINDATE SALARY
F01 Anishma Garg 2000-12-14 32000
F03 Bhumi Goel 2001-08-10 15000
F04 Neha Verma 2000-05-17 27000
F05 Meenu Sharma 2006-07-11 30000
Table: COURSES
C_ID FID CNAME FEES
C11 F01 Grid Computing 40000
C12 F04 Python 17000
C13 F03 C++ 8000
C14 F04 Computer Network 15000
C15 F01 HTML 12000
C16 F05 Data Science NULL
27 What will be the output of the following statement? 3
i SELECT FID, MIN(FEES), MAX(FEES) FROM COURSES GROUP
BY FID;
ii SELECT AVG(SALARY) FROM FACULTY WHERE FNAME LIKE
'%a';
iii SELECT FNAME, CNAME FROM FACULTY F, COURSES C WHERE
F.FID=C.FID AND COURSES.FID='F04';
iv SELECT FNAME, CNAME , FEES FROM FACULTY F , COURSES
36
C WHERE F.FID = C.FID AND FEE>15000;
(b) Write the name of the command to display the structure of a table
in a database.
Write a function COUNT() in Python to read from a text file
'Gratitude.txt' and display the count of the letter 'e' in each line
Example: If the file content is as follows:
Gratitude is a humble heart's radiant glow, A
timeless gift that nurtures and bestows. It's
the appreciation for the love we're shown, In
moments big and small, it's truly known.
The COUNT() function should display the output as:
Line 1 : 3
Line 2 : 4
Line 3 : 6
Line 4 : 1
OR
Write a function Start_with_I() in Python, which should read a text
file 'Gratitude.txt' and then display lines starting with 'I'.
Example: If the file content is as follows:
37
result, what will be the new degree and cardinality of the above
table?
iii Write a statement to increase the SEM2 marks by 3% for the students
securing marks between 70 to 100.
IDs of those students, from the dictionary Stu_dict into the stack
Stu_Stk, who have scored more than or equal to 80 marks in the TS3
Test.
(ii) Pop_elements(Stu_Stk): It removes all elements present
inside the stack in LIFO order and prints them. Also, the function displays
'Stack Empty' when there are no elements in the stack. Call both
functions to execute queries.
For example:
If the dictionary Stu_dict contains the following data:
Stu_dict ={5:(87,68,89), 10:(57,54,61), 12:(71,67,90),
14:(66,81,80), 18:(80,48,91)}
38
31 Create a function maxsalary() in Python to read all the records from 4
an already existing file record.csv which stores the records of various
employees working in a department. Data is stored under various fields
as shown below:
E_code E_name Scale Salary
A01 Bijesh Mehra S4 65400
B02 Vikram Goel S3 60000
C09 Suraj Mehta S2 45300
…… …… …… ……
Function should display the row where the salary is maximum.
Note: Assume that all employees have distinct salary.
32 Consider a binary file 'INVENTORY.DAT' that stores information about 4
products using tuple with the structure (ProductID, ProductName,
Quantity, Price). Write a Python function
expensiveProducts() to read the contents of
'INVENTORY.DAT' and display details of products with a price higher
than Rs. 1000. Additionally, calculate and display the total count of such
expensive products.
For example: If the file stores the following data in binary format
(1, 'ABC', 100, 5000)
(2, 'DEF', 250, 1000) (3,
'GHI', 300, 2000)
then the function should display
Product ID: 1
Product ID: 3
Total expensive products: 2
Q No. Questions Section-E (15 Marks) Marks
33 Fun Media Services Ltd is an event planning organization. It is planning to
set up its India campus in Mumbai with its head office in Delhi. The
Mumbai campus will have four blocks/buildings - ADMIN, DECORATORS,
FOOD, and MEDIA.
You as a network expert need to suggest the best network-related
solutions for them to resolve the issues/problems mentioned in points (i)
to (v), keeping in mind the distances between various blocks/buildings
and other given parameters.
39
5
40
34 i) Mention any two differences between seek() and tell(). 2+3=5
ii) Consider a file FLIGHT.DAT containing multiple records. The structure
of each record is as shown below:
[Fno, FName, Fare, Source, Destination]
Write a function COPY_REC() in Python that copies all those records from
FLIGHT.DAT where the source is DELHI and the
destination is MUMBAI, into a new file RECORD.DAT
OR
i) Mention any two differences between binary files and csv files?
ii) Consider a Binary file BOOK.DAT containing a dictionary having multiple
elements. Each element is in the form BNO:[BNAME,BTYPE,PRICE] as
key:value pair where
BNO – Book Number
BNAME – Book Name
BTYPE - Book Type
PRICE – Book price
Write a user-defined function, findBook(price), that accepts price as
parameter and displays all those records from the binary file BOOK.DAT
which has a book price more than or equal to the price value passed as a
parameter.
41
• Discount (Discount) – float
Note the following to establish connectivity between Python and MySQL:
• Username - root
• Password - tiger
• Host - localhost
Write a python code with mysql connectivity to run the query to display
details of all such items from the table ITEMS whose price is more than
5000.
42
Vivekananda Educational Society
Std :XI Quarterly Examination – 2024-2025 Time : 3 Hrs
Subject : Computer Science Marking Scheme - Set 2 (**) Max. Marks:70
SECTION A
1. False (it cannot be changed in place) 1
2. (d)Real 1
3. False 1
4. a) True 1
5. b) (3,4) 1
6. b. has the value True 1
7. a) List 1
8. all#around#the world 1
9. XNOR (option not given) 1
10. c) string 1
11. d) set 1
12. c) p = p – 5 1
13. b) if…elif 1
14. (a) 14.75 1
15. a) # 1
16. c) changeable 1
17. a) Both A and R are true and R is the correct explanation for A 1
18. a) Both A and R are true and R is the correct explanation for A 1
SECTION B
19. n=int(input("Enter number to check :: ")) 2
for i in range (2, n//2):
if n%i==0:
print("Number is not prime ")
break
else:
print("Number is prime”) ( ½ m for each )
20. for a in range(14,50,2): 2
print(a)
OR
a=0
while a<100:
a=a+6
print(a) (marks 1+1)
21. A’B+AB+B’C OR 2
Draw the Boolean circuit: A.B.C+(B'+C').A
22. =(assign value), += (add and assign), -= (subract and assign), *= (multiply and 2
assign), /= (divide and assign), //= (quotient and assign), **= (exponential
43
and assign), %= (modulus and assign)
½ m for 2 listing
23. Return type is str (string), it can be change used explicit type conversion 2
function like int(), float() etc 1+1
24. Can contain only a-z, A-Z, 0-9,_ 2
Cannot start with digit
Cannot be keyword (1 m each)
OR
a) 20-10 < 12
b) 14 %3 ==2 ( 1m each)
25. Predict the output of the Python code given below: 2
a)
1
3
5
7
9
(b) 4
4.25
or
1
2
3
SECTION C
26. Explain logical operators in python with example. 3
Logical operators – and, or, not
Ex :
True and True = True, True and Fasle = False, False and True = False, False
and False = False
True or True = True, True or Fasle = True, False and True = True, False and
False = False
not True = False, not False = True
(listing – 1m, example – 2m)
27 Break – the program control comes out of the loop, it can be given in loop only 3
Continue – the program control goes to the beginning of the loop, it can be
given in loop only
(1 ½ - break, 1 ½ - continue) – explanation with example can also be
considered.
Or
Else – is the last statement in ‘if’ conditional statement, it is optional, there
can be only one else in an ‘if’ statement, if must not have a condition.
elif – there can be any number of elif statement in ‘if’ conditional statement, it
is optional, there can be only one else in an ‘if’ statement, it should have
condition.
(1 ½ - else, 1 ½ - elif) – explanation with example can also be considered.
28 a) * is the repetition operator for string data, it repeats the string number of 3
times. Ex – ‘a’*5 -> aaaaa
b) ‘in’ and ‘not in’ is membership operator, is it used on a iterator it check for
the presence of a value. Ex – ‘o’ in ‘Good’ -> True
c) ‘is’ and ‘is not’ are identity operator, it is used to check whether two
variables are pointing to the same memory address
a=5
b=5
44
a is b -> True
1m for each
SECTION – E
33 n=int(input(‘enter a number:’)) 5
for a in str(n):
if n==’1’:
print(‘one’, end=’ ‘)
elif n==’2’:
print(‘two’, end=’ ‘)
elif n==’3’:
print(‘three’, end=’ ‘)
elif n==’4’:
print(‘four’, end=’ ‘)
elif n==’5’:
print(‘five’, end=’ ‘)
elif n==’6’:
45
print(‘six’, end=’ ‘)
elif n==’7’:
print(‘seven’, end=’ ‘)
elif n==’8’:
print(‘eight’, end=’ ‘)
elif n==’9’:
print(‘nine’, end=’ ‘)
elif n==’0’:
print(‘zero’, end=’ ‘)
Or
sal=int(input(‘enter salary:’))
if sal>0 and sal<=25000:
bonus=sal*0.25
elif sal>25000 and sal<=35000:
bonus=sal*0.15
elif sal>35000 and sal<=50000:
bonus=sal*0.10
elif sal>50000 and sal<=75000:
bonus=sal*0.05
elif sal>75000:
bonus=0
print(“Bonus:”,bonus)
(Any equivalent logic can be used to produce the output)
(1 m- input, 1 m- for, 3 m – if elif)
34 Convert the following : 5
a) 342.24 (10) to binary - 101010110.0011110101110000101
b) A21.13(16) to decimal - 2593.07421875
c) 674.34(8) to decimal- 444.4375
d) 11011.1101(2) to octal - 33.64
e) 457.45(8) to binary - 100101111.100101
Or
a) 5610(8) to binary - 101110001000
b) 76.25(10) to octal - 76.25
c) 10101100.01011(2) to octal - 254.26
d) 98E(16) to hexadecimal - already in hexadecimal
e) 101101.101(2) to decimal - 45.625
35 a) Operating system - system software that manages computer hardware, 5
software resources, and provides common services for computer
programs.
b) Packages – It is bundle of application readymade for a purpose
c) Utilities software – Utility software is a type of software that is designed
to help users manage, maintain, and optimize their computer systems.
d) Application software – software designed to handle specific tasks for
users.
e) Language processors - A language processor, or translator, is a
computer program that translates source code from one programming
language to another.
1m for each definition
46
Vivekananda Educational Society
Std :XI Quarterly Examination – 2024-2025 Time : 3 Hrs
Subject : Computer Science Marking Scheme - Set 1 (*) Max. Marks:70
SECTION A
1. b) continue 1
2. (d)Real 1
3. False 1
4. a) True 1
5. b) (3,4) 1
6. b. has the value True 1
7. a) List 1
8. all#around#the world 1
9. XNOR (option not given) 1
10. c) string 1
11. d) set 1
12. c) p = p - 5 1
13. b) if…elif 1
14. (a) 14.75 1
15. b) # 1
16. c) changeable 1
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17. a) Both A and R are true and R is the correct explanation for A 1
18. a) Both A and R are true and R is the correct explanation for A 1
SECTION B
19. n=int(input("Enter number to check :: ")) 2
for i in range (2, n//2):
if n%i==0:
print("Number is not prime ")
break
else:
print("Number is prime”) ( ½ m for each )
20. for a in range(14,50,2): 2
print(a)
OR
a=0
while a<100:
a=a+6
print(a) (marks 1+1)
47
21. A’B+AB+B’C OR 2
Draw the Boolean circuit: A.B.C+(B'+C').A
22. =(assign value), += (add and assign), -= (subract and assign), *= (multiply and 2
assign), /= (divide and assign), //= (quotient and assign), **= (exponential
and assign), %= (modulus and assign)
½ m for 2 listing
23. Return type is str (string), it can be change used explicit type conversion 2
function like int(), float() etc 1+1
24. Can contain only a-z, A-Z, 0-9,_ 2
Cannot start with digit
Cannot be keyword (1 m each)
OR
c) 20-10 < 12
d) 14 %3 ==2 ( 1m each)
25. Predict the output of the Python code given below: 2
a)
1
3
5
7
9
(b) 4
4.25
or
1
2
3
SECTION C
26. Explain logical operators in python with example. 3
Logical operators – and, or, not
Ex :
True and True = True, True and Fasle = False, False and True = False, False
and False = False
True or True = True, True or Fasle = True, False and True = True, False and
False = False
not True = False, not False = True
(listing – 1m, example – 2m)
27 Break – the program control comes out of the loop, it can be given in loop only 3
Continue – the program control goes to the beginning of the loop, it can be
given in loop only
(1 ½ - break, 1 ½ - continue) – explanation with example can also be
considered.
Or
Else – is the last statement in ‘if’ conditional statement, it is optional, there
can be only one else in an ‘if’ statement, if must not have a condition.
elif – there can be any number of elif statement in ‘if’ conditional statement, it
is optional, there can be only one else in an ‘if’ statement, it should have
48
condition.
(1 ½ - else, 1 ½ - elif) – explanation with example can also be considered.
28 d) * is the repetition operator for string data, it repeats the string number of 3
times. Ex – ‘a’*5 -> aaaaa
e) ‘in’ and ‘not in’ is membership operator, is it used on a iterator it check for
the presence of a value. Ex – ‘o’ in ‘Good’ -> True
f) ‘is’ and ‘is not’ are identity operator, it is used to check whether two
variables are pointing to the same memory address
a=5
b=5
a is b -> True
1m for each
29 range(start, stop, step) generates a range of values from start to stop-1 in 3
steps. Default start is 0 and step is 1
ex : range(5,10,2) -> 5,7,9
30 n=int(input(‘enter n value’)) 3
sum=0
for a in range(1,n,2):
sum=sum+a
print(sum)
½ m- input, 2 m – loop and sum , ½ m – output
SECTION – D
31 Repeating a set of statements until a condition is called looping. 4
for and while are looping structure in python
for a in range(1,100,2): a=5
print(a) while a<20:
print(a)
a=a+2
1 m – explanation, 1m for listing , 1m for each example (1+1)
32 a) X+YZ=(X+Y).(X+Z) 4
b) A+A’B=A+B
SECTION – E
49
33 n=int(input(‘enter a number:’)) 5
for a in str(n):
if n==’1’:
print(‘one’, end=’ ‘)
elif n==’2’:
print(‘two’, end=’ ‘)
elif n==’3’:
print(‘three’, end=’ ‘)
elif n==’4’:
print(‘four’, end=’ ‘)
elif n==’5’:
print(‘five’, end=’ ‘)
elif n==’6’:
print(‘six’, end=’ ‘)
elif n==’7’:
print(‘seven’, end=’ ‘)
elif n==’8’:
print(‘eight’, end=’ ‘)
elif n==’9’:
print(‘nine’, end=’ ‘)
elif n==’0’:
print(‘zero’, end=’ ‘)
Or
sal=int(input(‘enter salary:’))
if sal>0 and sal<=25000:
bonus=sal*0.25
elif sal>25000 and sal<=35000:
bonus=sal*0.15
elif sal>35000 and sal<=50000:
bonus=sal*0.10
elif sal>50000 and sal<=75000:
bonus=sal*0.05
elif sal>75000:
bonus=0
print(“Bonus:”,bonus)
(Any equivalent logic can be used to produce the output)
(1 m- input, 1 m- for, 3 m – if elif)
34 Convert the following : 5
f) 427.56(10) to binary - 110101001.1000111101
g) C47.15(16) to decimal - 3143.08203125
h) 573.64(8) to decimal- 379.8125
i) 11101.101(2) to decimal - 29.625
j) 723.47(8) to binary - 111010011.100111
Or
f) 100101.101(2) to decimal - 37.625
g) 605.12(8) to decimal - 389.15625
h) 100.25(10) to hexadecimal - 64.4
i) 132.45(16) to binary - 100110010.01000101
j) 65.203(8) to binary - 110101.010000011
35 f) Assembler – converts assembly language to machine language 5
g) Interpreter – converts HLL to machine language line by line.
h) System software – a program designed to run a computer's hardware
and applications and manage its resources
50
i) Software – a program designed to run a computer's hardware and
applications and manage its resources
j) Disk Defragmentor - rearranges fragmented data so your disks and
drives can work more efficiently
1m for each definition
51
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL, CHENNAI - 39
52
14. Which of following datatype not supported by python- 1
(a) float (b) Complex (c) List (D) Date
15. Which of these is a sequence data types? 1
(a) integer ` (b) Boolean (c) List (d) Set
16. It is a ____________ Logical Gate 1
or
Draw the Boolean circuit for the following expression :
XYZ’+(Z'+Y')
53
SECTION C
26. What is syntax error? Give example. 3
27 What is the difference between pass and break? Explain with example. 3
Or
What is the difference between // and / operator? Explain with example.
28 What is output from the following code : 3
(i)range(6) (iii)range(5,20,4) (ii)range(7,10) (iv)range (12,1,-2) (v)
range(10,2) (vi) range(-2,-6,-2)
29 Write a loop to print the following pattern : 3
1
2 1 2
3 2 1 2 3
4 3 2 1 2 3 4
Or
Write a program to print the sum of digit of a number. For Ex : if number is
342 then the sum of digits is 9 (3+4+2)
30 What is an infinite loop? Give example. 3
SECTION – D
31 Explain the different types of operators in python with example. 4
32 Draw NAND and NOR gates with truth table for 2 variables. 4
SECTION – E
33 Write a program to check whether an year is leap or not 5
Or
Write a Python program to calculate electricity bill based on :
No. of units Rate per unit
0 to 100 - Rs. 2
101 to 300 Rs. 3
Ex : if the units is 120 the amount is 200+20 x 3=260
34 Convert the following : 5
a) 251.543(10) to binary
b) 341.B(16) to decimal
c) 76.34(8) to hexadecimal
d) 1110.1101(2) to octal
e) 574.45(8) to decimal
35 Define the following and give an example for each one of them: 5
a) Dynamic RAM b) Hardware c) Secondary Memory d) Register e) bit
54
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL, CHENNAI - 39
55
13 Fill in the blank: 1
clause is used in the SQL query to display the data in ascending order.
(a) DESC (b)ORDER BY (c)GROUP BY (d)UPDATE
14 What will the output following expression when evaluated in Python? 1
10*1*2**4-4//4
15 Which function is used to display the latest date a from table in a database? 1
(a)MAX (b)AVG (c)LARGEST (d) MIN
16 State True or False “Variable declaration is implicit in Python.” 1
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as:
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
A is false but R is True
17 Assertion (A):- If the arguments in function call statement match the number and 1
order of arguments as defined in the function definition, such arguments are called
positional arguments. Reasoning (R):- During a function call, the argument list first
contains default argument(s) followed by positional argument(s).
18 Assertion (A): CSV (Comma Separated Values) is a file format for data storage which 1
looks like a text file. Reason (R): The information is organized with one record on each
line and each field is separated by comma.
Section B
19 Rajat has written the following Python code. There are some errors in it. 2
Rewrite the correct code and underline the corrections made.
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()
20 Differentiate between char and varchar in SQL with appropriate examples. 2
OR
What are different types of SQL Aggregate Functions? Give two examples.
21 a. Find output generated by the following 1+1
code: mystr = “Hello I am a Human.”
print(mystr[::-3])
56
<60 C
For example: Consider the following dictionary
S={"AMIT": [92,86,64],"NAGMA": [65, 42, 43], "DAVID": [92,90,88]}
The output should be:
AMIT B
NAGMA C
DAVID A
Or
Write a user defined function in Python named Puzzle (W, N) which takes the argument
Was an English word and N as an integer and returns the string where every Nth
alphabet of the word is replaced with an underscore ("_").
For example: if W contains the word "TELEVISION" and N is 3, then the function should
return the string "TE_EV_SI_N". Likewise for the word "TELEVISION" if N is 4, then the
function should return "TEL_VIS_ON".
24 Predict the output of the following code:
mylist=[2,14,54,22,17]
tup=tuple(mylist)
for i in tup:
print(i%3, end=",") or
24 def CALLME(n1=1,n2=2): 2
n1=n1*n2
n2+=2
print(n1,n2)
CALLME()
CALLME(3)
25 (A) Write the Python statement for each of the following tasks using built-in 2
functions/methods only:
(i) To remove the item whose key is "NISHA" from a dictionary named Students.
For example, if the dictionary Students contains {"ANITA":90, "NISHA": 76, "ASHA":92),
then after removal the dictionary should contain ("ANITA":90, "ASHA":92}
(ii) To display the number of occurrences of the substring "is" in a string named
message. For example if the string message contains "This is his book", then the output
will be 3.
OR
(B) A tuple named subject stores the names of different subjects. Write the Python
commands to convert the given tuple to a list and thereafter delete the last element of
the list.
Section-C
26 a. Consider the following tables Trainer and Course: 1+2
57
What will be the output of the following statement? SELECT * FROM TRAINER NATURAL
JOIN COURSE;
a. Write the Outputs of the MySQL queries(i) to(iv)based on the given above tables:
i. SELECT DISTINCT(CITY) FROM TRAINER WHERE SALARY>80000;
ii. SELECT TID,COUNT(*),MAX(FEES) FROM COURSE GROUP BY TID HAVING
COUNT(*)>1;
58
i. SELECT Department, count(*) FROM Teacher GROUP BY Department;
ii. SELECT Max(Date_of_Join),Min(Date_of_Join) FROM Teacher;
iii. SELECT Teacher.name, Teacher.Department, Posting.Place FROM Teacher, Posting
WHERE Teacher.Department=Posting.Department AND Posting.Place=”Delhi”;
iv. SELECT Gender, COUNT(Gender) FROM Teacher GROUP BY Gender;
59
i) Display no. of employees from each department
ii) Display details of workers from Finance department
iii) Show the name and age of the workers when they joined the company.
iv) Show the names of the workers whose name starts with ‘M’ or ‘G’
Section-E
33 What is the use of tell() function? 1+4
Write a program in Python that defines and calls the following user defined functions:
i. Add(): to add the record of a student to a csv file “record.csv”. Each record
should be with field elements [admno,sname,class]
ii. Count(): to count the number of students studying in class 12
OR
Give a difference between dump and load function. Write a program in Python that
defines and calls the following user defined functions:
i. Add(): to add the record of an animal to a csv file “animal.csv”. Each record
should be with field elements [animalname, animaltype, animalfood]
ii. Search(): to print all the animal names who eat grass as their food.
34 (a) Write a function countNow(PLACES) in Python, that takes the dictionary, PLACES as an 3+2
argument and displays the names (in uppercase)of the places whose names are longer
than 5 characters. For example, Consider the following dictionary
PLACES={1:"Delhi",2:"London",3:"Paris",4:"New York",5:"Doha"}
The output should be:
LONDON
NEW YORK
(b)Find the output
Msg1="WeLcOME"
Msg2="GUeSTs" Msg3=""
for Iin range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print(Msg3)
35 What is the advantage of using pickle module? 5
Write a program to write into a CSV file “one.csv” Rollno, Name and Marks separated
by comma. It should have header row and then take input from the user for all
following rows. The format of the file should be as shown if user enters 2 records.
Roll.No, Name, Marks
20, Ronit, 67
56, Nihir, 69
OR
What is difference between tell() and seek()methods?
Write a program to read all content of “student.csv” and display records of only those
students who scored more than 80 marks. Records stored in students is in format :
[Rollno, Name, Marks]
60
61
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL, CHENNAI - 39
62
13 Fill in the blank: 1
clause is used in the SQL query to display the data in ascending order.
(b) DESC (b)ORDER BY (c)GROUP BY (d)UPDATE
14 What will the output following expression when evaluated in Python? 1
10*1*2**4-4//4
15 Which function is used to display the latest date a from table in a database? 1
(a)MAX (b)AVG (c)LARGEST (d) MIN
16 State True or False “Variable declaration is implicit in Python.” 1
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as:
(d) Both A and R are true and R is the correct explanation for A
(e) Both A and R are true and R is not the correct explanation for A
(f) A is True but R is False
A is false but R is True
17 Assertion (A):- If the arguments in function call statement match the number and 1
order of arguments as defined in the function definition, such arguments are called
positional arguments. Reasoning (R):- During a function call, the argument list first
contains default argument(s) followed by positional argument(s).
18 Assertion (A): CSV (Comma Separated Values) is a file format for data storage which 1
looks like a text file. Reason (R): The information is organized with one record on each
line and each field is separated by comma.
Section B
19 Rajat has written the following Python code. There are some errors in it. 2
Rewrite the correct code and underline the corrections made.
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()
20 Differentiate between char and varchar in SQL with appropriate examples. 2
OR
What are different types of SQL Aggregate Functions? Give two examples.
21 c. Find output generated by the following 1+1
code: mystr = “Hello I am a Human.”
print(mystr[::-3])
63
<60 C
For example: Consider the following dictionary
S={"AMIT": [92,86,64],"NAGMA": [65, 42, 43], "DAVID": [92,90,88]}
The output should be:
AMIT B
NAGMA C
DAVID A
Or
Write a user defined function in Python named Puzzle (W, N) which takes the argument
Was an English word and N as an integer and returns the string where every Nth
alphabet of the word is replaced with an underscore ("_").
For example: if W contains the word "TELEVISION" and N is 3, then the function should
return the string "TE_EV_SI_N". Likewise for the word "TELEVISION" if N is 4, then the
function should return "TEL_VIS_ON".
24 Predict the output of the following code:
mylist=[2,14,54,22,17]
tup=tuple(mylist)
for i in tup:
print(i%3, end=",") or
24 def CALLME(n1=1,n2=2): 2
n1=n1*n2
n2+=2
print(n1,n2)
CALLME()
CALLME(3)
25 (A) Write the Python statement for each of the following tasks using built-in 2
functions/methods only:
(i) To remove the item whose key is "NISHA" from a dictionary named Students.
For example, if the dictionary Students contains {"ANITA":90, "NISHA": 76, "ASHA":92),
then after removal the dictionary should contain ("ANITA":90, "ASHA":92}
(ii) To display the number of occurrences of the substring "is" in a string named
message. For example if the string message contains "This is his book", then the output
will be 3.
OR
(B) A tuple named subject stores the names of different subjects. Write the Python
commands to convert the given tuple to a list and thereafter delete the last element of
the list.
Section-C
26 a. Consider the following tables Trainer and Course: 1+2
64
What will be the output of the following statement?
SELECT * FROM TRAINER NATURAL JOIN COURSE;
b. Write the Outputs of the MySQL queries(i) to(iv)based on the given above tables:
a. SELECT DISTINCT(CITY) FROM TRAINER WHERE SALARY>80000;
b. SELECT TID,COUNT(*),MAX(FEES) FROM COURSE GROUP BY TID HAVING
COUNT(*)>1;
c. SELECT T.TNAME,C.CNAME FROM TRAINER T,COURSE C WHERE T.TID=C.TID AND
T.FEES<10000;
SELECT COUNT(CITY),CITY FROM TRAINER GROUP BY CITY;
27 (A) Write a user defined function in Python named showInLines() which reads contents of
a text file named STORY.TXT and displays every sentence in a separate line.Assume that a
sentence ends with a full stop (.), a question mark (?), or an exclamation mark (!).
For example, if the content of file STORY. TXT is as follows:
Our parents told us that we must eat vegetables to be healthy. And it turns out, our
parents were right! So, what else did our parents tell?
Then the function should display the file's content as follows:
Our parents told us that we must eat vegetables to be healthy.
And it turns out, our parents were right! So, what else did our parents tell?
OR
(B) Write a function, c_words () in Python that separately counts and displays the number
of uppercase and lowercase alphabets in a text file, Words.txt.
28 Python function oddeve(L) to print positive numbers in a list L. 3
Example: Input:[4, -1,5, 9,-6, 2,-9, 8]
Output: [4, 5, 9, 2,8]
29 Write the output on execution of the following 3
Python code:
S="Racecar Car Radar" L=S.split()
for Win L:
x=W.upper()
if x==x[::-1]:
for I in x:
print (I, end="*")
else:
for I in W:
print (I, end="#")
print()
30 b. Write the outputs of the SQL queries (i) to (iv)based on the relations Teacher and 3
Posting given below:
65
v. SELECT Department, count(*) FROM Teacher GROUP BY Department;
vi.SELECT Max(Date_of_Join),Min(Date_of_Join) FROM Teacher;
vii.SELECT Teacher.name, Teacher.Department, Posting.Place FROM Teacher, Posting
WHERE Teacher.Department=Posting.Department AND Posting.Place=”Delhi”;
viii. SELECT Gender, COUNT(Gender) FROM Teacher GROUP BY Gender;
66
v)Display no. of employees from each department
vi)Display details of workers from Finance department
vii) Show the name and age of the workers when they joined the company.
viii) Show the names of the workers whose name starts with ‘M’ or ‘G’
Section-E
33 What is the use of tell() function? 1+4
Write a program in Python that defines and calls the following user defined functions:
iii. Add(): to add the record of a student to a csv file “record.csv”. Each record
should be with field elements [admno,sname,class]
iv. Count(): to count the number of students studying in class 12
OR
Give a difference between dump and load function. Write a program in Python that
defines and calls the following user defined functions:
iii. Add(): to add the record of an animal to a csv file “animal.csv”. Each record
should be with field elements [animalname, animaltype, animalfood]
iv. Search(): to print all the animal names who eat grass as their food.
34 a) Write a function INDEX_LIST(L), where L is the list of elements passed as argument to the 3+2
function. The function returns another list named ‘indexList’ that stores the indices of all
Non-Zero Elements of L.
For example: If L contains [12,4,0,11,0,56] The indexList will have - [0,1,3,5]
67
students who scored more than 80 marks. Records stored in students is in format :
[Rollno, Name, Marks]
68
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL, CHENNAI - 39
69
15. Which of these is a sequence data types? 1
(a) integer ` (b) Boolean (c) List (d) Set
16. It is a ____________ Logical Gate 1
or
Draw the Boolean circuit for the following expression :
XYZ’+(Z'+Y')
22. What is debugging? 2
23. What is the purpose of id() in python? 2
24. Differentiate between ‘is’ operator and ‘in’ operator with 2
example.
OR
Evaluate 13+11-6*2 > 14 or “End” and “False”
25. Draw the flowchart to find the area of a rectangle. 2
or
Draw a flowchart to find the biggest of 2 numbers.
70
SECTION C
26. What is syntax error? Give example. 3
27 What is the difference between pass and break? Explain with example. 3
Or
What is the difference between // and / operator? Explain with example.
28 What is output from the following code : 3
(i)range(6) (iii)range(5,20,4) (ii)range(7,10) (iv)range (12,1,-2) (v)
range(10,2) (vi) range(-2,-6,-2)
29 Write a loop to print the following pattern : 3
1
2 1 2
3 2 1 2 3
4 3 2 1 2 3 4
Or
Write a program to print the sum of digit of a number. For Ex : if number is
342 then the sum of digits is 9 (3+4+2)
30 What is an infinite loop? Give example. 3
SECTION – D
31 Explain the different data types of python with example. 4
32 Draw NAND and NOR gates with truth table for 2 variables. 4
SECTION – E
33 Write a program to check whether an year is leap or not 5
Or
Write a Python program to calculate electricity bill based on :
No. of units Rate per unit
0 to 100 - Rs. 2
101 to 300 Rs. 3
Ex : if the units is 120 the amount is 200+20 x 3=260
34 Convert the following : 5
f) 189.23(10) to binary
g) 211.A(16) to decimal
h) 79.34(8) to hexadecimal
i) 11011.1101(2) to octal
j) 457.45(8) to decimal
35 Define the following and give an example for each one of them: 5
b) Dynamic RAM b) Hardware c) Secondary Memory d) Register e) bit
71
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL, CHENNAI - 39
72
15. Which of these is a sequence data types? 1
(a) integer ` (b) Boolean (c) List (d) Set
16. It is a ____________ Logical Gate 1
or
Draw the Boolean circuit for the following expression :
XYZ’+(Z'+Y')
22. What is debugging? 2
23. What is the purpose of id() in python? 2
24. Differentiate between ‘is’ operator and ‘in’ operator with 2
example.
OR
Evaluate 13+11-6*2 > 14 or “End” and “False”
73
25. Draw the flowchart to find the area of a rectangle. 2
or
Draw a flowchart to find the biggest of 2 numbers.
SECTION C
26. What is syntax error? Give example. 3
27 What is the difference between pass and break? Explain with example. 3
Or
What is the difference between // and / operator? Explain with example.
28 What is output from the following code : 3
(i)range(6) (iii)range(5,20,4) (ii)range(7,10) (iv)range (12,1,-2) (v)
range(10,2) (vi) range(-2,-6,-2)
29 Write a loop to print the following pattern : 3
1
2 1 2
3 2 1 2 3
4 3 2 1 2 3 4
Or
Write a program to print the sum of digit of a number. For Ex : if number is
342 then the sum of digits is 9 (3+4+2)
30 What is an infinite loop? Give example. 3
SECTION – D
31 Explain tokens in python with example. 4
32 Draw XOR and XNOR gates with truth table for 2 variables. 4
SECTION – E
33 Write a program to check whether an year is leap or not 5
Or
Write a Python program to calculate electricity bill based on :
No. of units Rate per unit
0 to 100 - Rs. 2
101 to 300 Rs. 3
Ex : if the units is 120 the amount is 200+20 x 3=260
34 Convert the following : 5
a) 189.23(10) to binary
b) 211.A(16) to decimal
c) 79.34(8) to hexadecimal
d) 11011.1101(2) to octal
e) 457.45(8) to decimal
35 Define the following and give an example for each one of them: 5
g) Harddisk b) Control unit c) Static RAM d) Byte e) System bus
74
Vivekananda Educational Society
75
14. What will the output of the following expression if evaluated in Python? 1
print(15.0 / 4 + (8 + 3.0))
(a) 14.75 (b)14.0 (c) 15 (d) 15.5
15. Which symbol is used to comment a line in python? 1
c) # b) $ c) % d) @
16. In python, the term mutable means: 1
a. memory-efficient b. fixed c. changeable d. sequential
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
(q) Both A and R are true and R is the correct explanation for A
(r) Both A and R are true and R is not the correct explanation for A
(s) A is True but R is False
(t) A is false but R is True
17. Assertion (A):- ** will be evaluated before / and * in an expression. 1
or
Draw the Boolean circuit for the following expression :
A.B.C+(B'+C').A
22. Write the symbol of 8 assignment operators and its meaning. 2
23. What is the default return type of input() and how can it be changed? 2
76
24. List the rules of naming the identifiers. 2
OR
Write the logical expression corresponding to the following statement in
python:
e) The sum of 20 and -10 is less than 12
f) Remainder of 14 divided by 3 is equal to 2
SECTION C
26. Explain logical operators in python with example. 3
27 What is the difference between break and continue? 3
Or
What is the difference between else and elif construct in if statement?
28 h) What is repetition operator? Give example. 3
i) What is membership operator? Give example.
j) What is identity operator? Give example.
29 What is the use of range() function? Explain the purpose of each parameter? 3
30 Differentiate between break and continue statements with example. 3
SECTION – D
31 What is meant by looping structure? Give example of looping structures in 4
python.
32 Prove the following using truth table : 4
a) X+YZ=(X+Y).(X+Z) b) A+A’B=A+B
SECTION – E
33 Write a program to convert a number entered by the user into its 5
corresponding number in words. For example, if the input is 876 then the
output should be ‘Eight Seven Six’.
Or
Write a Python program to calculate bonus as the following criteria using if-
elif statement :
If salary between bonus
0 to 25000 - 25% of salary
25001 to 35000 - 15% of salary
35001 to 50000 - 10% of salary
50001 to 75000 - 05 % of salary
77
75001 and above nil
78
9. Which gate returns true if both inputs are similar otherwise false 1
(a) AND (b) OR (c) XOR (d) NOR
10. Which type of value is returned by the input() function. 1
a. integer b. float c. string d. no value
11. Which of these Python data structures cannot have duplicate items and does 1
not support ordering?
a) list b) tuple c) dictionary d) set
12. The statement p -= 5 has the same effect as which of these statements? 1
a) p = 5 b) p = -5 c) p = p - 5 d) p = 5 – p
13. Which statement is used for checking multiple conditions in Python? 1
a. else if b. if…elif c. switch d. None of the above
14. What will the output of the following expression if evaluated in Python? 1
print(15.0 / 4 + (8 + 3.0))
(a) 14.75 (b)14.0 (c) 15 (d) 15.5
15. Which symbol is used to comment a line in python? 1
d) # b) $ c) % d) @
16. In python, the term mutable means: 1
a. memory-efficient b. fixed c. changeable d. sequential
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
(u) Both A and R are true and R is the correct explanation for A
(v) Both A and R are true and R is not the correct explanation for A
(w) A is True but R is False
(x) A is false but R is True
17. Assertion (A):- ** will be evaluated before / and * in an expression. 1
79
21. Write the Boolean expression for the following circuit 2
or
Draw the Boolean circuit for the following expression :
A.B.C+(B'+C').A
22. Write the symbol of 6 relational operators and its meaning. 2
23. What is the default return type of input() and how can it be changed? 2
24 List the rules of naming the identifiers. 2
OR
Write the logical expression corresponding to the following statement in
python:
a) The sum of 20 and -10 is less than 12
b) Remainder of 14 divided by 3 is equal to 2
25. Predict the output of the Python code given below: 2
a)
X=range(1,10,2)
for i in X:
print(i)
(b)
X,Y=17,4
print (X//Y)
print(X/Y)
or
i=1
while i < 6:
print(i)
if i == 3:
break
i += 1
SECTION C
26. Explain logical operators in python with example. 3
27 What is the difference between break and continue? 3
Or
What is the difference between else and elif construct in ‘if’ statement?
28 k) What is repetition operator? Give example. 3
l) What is membership operator? Give example.
m) What is identity operator? Give example.
29 What is the use of range() function? Explain the purpose of each parameter. 3
Or
What is meant by looping structure? Give example of looping structure in
python.
30 Differentiate between break and continue statements with example. 3
SECTION – D
80
31 Explain syntax error, runtime error and logical error with example. 4
32 State and verify Demorgans theorem using truth table. 4
SECTION – E
33 Write a program to convert a number entered by the user into its 5
corresponding number in words. For example, if the input is 876 then the
output should be ‘Eight Seven Six’.
Or
Write a Python program to calculate bonus as the following criteria using if-
elif statement :
If salary between bonus
0 to 25000 - 25% of salary
25001 to 35000 - 15% of salary
35001 to 50000 - 10% of salary
50001 to 75000 - 05 % of salary
75001 and above nil
34 Convert the following : 5
p) 342.24(10) to binary
q) A21.13(16) to decimal
r) 674.34(8) to decimal
s) 11011.1101(2) to decimal
t) 457.45(8) to binary
35 Define the following and give an example for each one of them: 5
c) Operating system b) Packages c) Utilities
n) Application Software e) Language processors
81
82
II. Write python program for the following : (4)
To accept length, breadth and height of a cuboid and print its volume (lxbxh) and Total
Surface area 2 (lb+bh+lh). (4)
To accept length, breadth and height of a cuboid and print its volume (lxbxh) and Total
Surface area 2 (lb+bh+lh). (4)
83
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL, CHENNAI – 39
Text and CSV File handling – 2024-2025 (July )
Class : XII Subject : Computer Science
Answer the following questions (4x3=12)
1. Write a function in Python that displays the book names having y in their name
from a text file Bookname.txt
Example : If the file Bookname.txt contains the names of following books :
One Hundred Years of Solitude
The Diary of a Young Girl
On the Road
After execution, the output will be :
One Hundred Years of Solitude
The Diary of a Young Girl
2. Write a function RevString() to read the textfile ‘Input.txt’ and prints the words
starting with ‘O’ in the reverse order. The rest of the content is displayed normally.
Example :
If content in the text file is :
UBUNTU IS AN OPEN SOURCE OPERATING SYSTEM
Output will be :
UBUNTU IS AN NEPO SOURCE GNITAREPO SYSTEM
(the words OPEN and OPERATING are displayed in reverse order)
3. Write a function, vowelCount() in Python that counts and displays the number of
vowels in the text file named Poem.txt.
------------------------------------------------------------------------------------------------------------------
2. Write a function RevString() to read the textfile ‘Input.txt’ and prints the words
starting with ‘O’ in the reverse order. The rest of the content is displayed normally.
Example :
84
If content in the text file is :
UBUNTU IS AN OPEN SOURCE OPERATING SYSTEM
Output will be :
UBUNTU IS AN NEPO SOURCE GNITAREPO SYSTEM
(the words OPEN and OPERATING are displayed in reverse order)
3. Write a function, vowelCount() in Python that counts and displays the number of
vowels in the text file named Poem.txt.
4. Write a function biglines() in Python to read a text file, Alpha.txt and displays those
lines which have more then 5 words in it.
4. Write a function biglines() in Python to read a text file, Alpha.txt and displays those
lines which have more then 5 words in it.
85
Accept() – to accept a record from the user and add it to the file Result.csv. The
column headings should also be added on top of the csv file.
wonCount() – to count the number of students who have won any event. As a Python
expert, help him complete the task. (3+3)
1. Write a code to catch the ZeroDivisionError and display appropriate message. (3)
2. What is the output of the following Code : (3)
------------------------------------------------------------------------------------------------------------------
1. Write a code to catch the ZeroDivisionError and display appropriate message. (3)
2. What is the output of the following Code :
86
3. Write a function INDEX_LIST(L), where L is the list of elements passed as
argument to the function. The function returns another list named ‘indexList’ that
stores the indices of all Non-Zero Elements of L.
For example: If L contains [12,4,0,11,0,56] The indexList will have - [0,1,3,5]
4. Write a function, lenWords(STRING), that takes a string as an argument and
returns a tuple containing length of each word of a string. For example, if the string is
"Come let us have some fun", the tuple will have (4, 3, 2, 4, 4, 3)
87
5. Write a function countNow(PLACES) in Python, that takes the dictionary, PLACES
as an argument and displays the names (in uppercase)of the places whose names
are longer than 5 characters. For example, Consider the following dictionary
PLACES={1:"Delhi",2:"London",3:"Paris",4:"New York",5:"Doha"}
The output should be: LONDON NEW YORK
6. Write a Python program that prompts the user to input an integer and raises a
ValueError exception if the input is not a valid integer.
7. Write a Python program that prompts the user to input age and raises an
AssertionError exception if the input is not a valid age. Note : valid age is between 1
to 100
8. Given the following code : (4)
try:
print(a//b)
except ZeroDivisionError:
print('Cannot be divided')
except:
print('Check input')
else:
print('Bugs are not common')
finally:
print('python')
Predict the output for the following input values
i) a=10, b=5 iii) a=6, b=0
ii) a='start', b=2 iv) a=’good’, b=’end'
------------------------------------------------------------------------------------------------------------------
88
iii) a=6, b=0 iv) a=’good’, b=’end'
1. List the digits of decimal, binary, octal and hexadecimal numbers. (3)
------------------------------------------------------------------------------------------------------------------
1. List the digits of decimal, binary, octal and hexadecimal numbers. (3)
------------------------------------------------------------------------------------------------------------------
1. List the digits of decimal, binary, octal and hexadecimal numbers. (3)
91
the list must be ['C', 'o', 'm', 'p', 'u', 't', 'e', 'r', ' ', 'S', 'c', 'i', 'n', '1', '2']
Section B (7x2=14)
19. Write loop structure to generate the following pattern upto ‘n’ value :
1
12
123
1234
21. From the options given below find the possible outputs(s) that will be displayed on screen
at the time of execution of the program from the following code? Also specify the maximum
values that can be assigned to each of the variables Lower and Upper.
import random
AR=[20,30,40,50,60,70]
Lower =random.randint(1,3)
Upper =random.randint(2,4)
for K in range(Lower, Upper +1):
print (AR[K],end=”#“)
(i) 10#40#70# (ii) 30#40#50# (iii) 50#60#70# (iv) 40#50#70#
22. Write the Python statement for each of the following tasks using BUILT-IN
functions/methods only:
(i) To insert an element 200 at the third position, in the list L1.
(ii) To check whether a string named, message ends with a full stop / period or not.
23. Draw a flowchart to accept 3 numbers and print biggest and smallest among the 3.
24. Rewrite the following code after removing the errors, underline each correction :
Section C (5x3=15)
26. Predict the output of the code given below :
Krrishnav is looking for his dream job but has some restrictions. He loves Delhi and would take
a job there if he is paid over Rs.40,000 a month. He hates Chennai and demands at least Rs.
1,00,000 to work there. In any another location he is willing to work for Rs. 60,000 a month.
The following code shows his basic strategy for evaluating a job offer.
Code:
pay= _________
location= _________
if location == "Mumbai":
print ("I’ll take it!") #Statement 1
elif location == "Chennai":
if pay < 100000:
print ("No way") #Statement 2
else:
print("I am willing!") #Statement 3
elif location == "Delhi" and pay > 40000:
print("I am happy to join") #Statement 4
elif pay > 60000:
print("I accept the offer") #Statement 5
else:
print("No thanks, I can find something better")#Statement 6
On the basis of the above code, write the output when different inputs for pay and location are
given.
a) Input: location = "Chennai”, pay = 50000
b) Input: location = "Surat" ,pay = 50000
c) Input location = "Delhi", pay = 500000
28. Explain gender and disability issues with teaching and using computers.
29. Mention any 3 ways of proper disposal of used electronic gadgets.
30. How are interpreters, compilers and assemblers different from each other?
Section D (2x4=8)
31.Define the following terms :
a) Malware b) Ransomware c) Trojan horse d) eavesdropping
32. Write a code to create a list of numbers . Accept a number and display the position of the
number in the list along with its number of occurrences. Eg: if the list contains
[2,12,3,4,5,6,2,4,2] then output must be
Enter number to search :2
Number 2 is found at position 1, 8 and 9
2 is found 3 times in the list.
Section E (3x5=15)
33.Convert the following numbers :
a) 165.32(8) to decimal
b) A2C.47(16) to octal
c) 101010.101(2) to decimal
34. Write a python code to create a dictionary of team name the wins and losses, get the input
from the user. Team namwe is the key and wins and losses is the value Eg :
{‘csk’:(5,4),’rcb’:(6,4)}. Using the dictionary perform the following:
a) Get the team name from the user and display the wins, losses and total number of matches
b) Display the teams which has more wins than losses.
Or
Write a python code to accept a string and create a tuple with number of characters of each
word. Eg: If the string is “Make hay when the sunshines.”, the tuple created must be (4,3,4,3,10).
Display the biggest word in the string.
35. Write a python code to accept the salary from the user and expenditure under various heads
like grocery, entertainment and house rent. Find the balance amount left after all expenditure, if
the amount is
>= 10,000 – display ‘you can buy an car in loan’
>20,000 – display ‘ you can buy a house in loan’
>40,000 – display ‘ you can buy both car and house on loan’
<10,000 - display ‘earn more or save more for future plans’
Section B (7x2=14)
19. Write loop structure to generate the following pattern upto ‘n’ value :
1
22
333
4444
21. From the options given below find the possible outputs(s) that will be displayed on screen
at the time of execution of the program from the following code? Also specify the maximum
values that can be assigned to each of the variables Lower and Upper.
import random
AR=[20,30,40,50,60,70]
Lower =random.randint(1,3)
Upper =random.randint(2,4)
for K in range(Lower, Upper +1):
print (AR[K],end=”#“)
(i) 10#40#70# (ii) 30#40#50# (iii) 50#60#70# (iv) 40#50#70#
22. Write the Python statement for each of the following tasks using BUILT-IN
functions/methods only:
(i) To insert an element 200 at the third position, in the list L1.
(ii) To check whether a string named, message ends with a full stop / period or not.
23. Draw a flowchart to accept 3 numbers and print biggest and smallest among the 3.
24. Rewrite the following code after removing the errors, underline each correction :
Section C (5x3=15)
26. Predict the output of the code given below :
Krrishnav is looking for his dream job but has some restrictions. He loves Delhi and would take
a job there if he is paid over Rs.40,000 a month. He hates Chennai and demands at least Rs.
1,00,000 to work there. In any another location he is willing to work for Rs. 60,000 a month.
The following code shows his basic strategy for evaluating a job offer.
Code:
pay= _________
location= _________
if location == "Mumbai":
print ("I’ll take it!") #Statement 1
elif location == "Chennai":
if pay < 100000:
print ("No way") #Statement 2
else:
print("I am willing!") #Statement 3
elif location == "Delhi" and pay > 40000:
print("I am happy to join") #Statement 4
elif pay > 60000:
print("I accept the offer") #Statement 5
else:
print("No thanks, I can find something better")#Statement 6
On the basis of the above code, write the output when different inputs for pay and location are
given.
d) Input: location = "Chennai”, pay = 50000
e) Input: location = "Surat" ,pay = 50000
f) Input location = "Delhi", pay = 500000
28. Explain gender and disability issues with teaching and using computers.
Section D (2x4=8)
31.Define the following terms :
a) Malware b) Ransomware c) Trojan horse d) eavesdropping
32. Write a code to create a list of numbers . Accept a number and display the position of the
number in the list along with its number of occurrences. Eg: if the list contains
[2,12,3,4,5,6,2,4,2] then output must be
Enter number to search :2
Number 2 is found at position 1, 8 and 9
2 is found 3 times in the list.
Section E (3x5=15)
33.Convert the following numbers :
d) 165.32(8) to decimal
e) A2C.47(16) to octal
f) 101010.101(2) to decimal
34. Write a python code to create a dictionary of team name the wins and losses, get the input
from the user. Team namwe is the key and wins and losses is the value Eg :
{‘csk’:(5,4),’rcb’:(6,4)}. Using the dictionary perform the following:
a) Get the team name from the user and display the wins, losses and total number of matches
b) Display the teams which has more wins than losses.
Or
Write a python code to accept a string and create a tuple with number of characters of each
word. Eg: If the string is “Make hay when the sunshines.”, the tuple created must be (4,3,4,3,10).
Display the biggest word in the string.
35. Write a python code to accept the salary from the user and expenditure under various heads
like grocery, entertainment and house rent. Find the balance amount left after all expenditure, if
the amount is
>= 10,000 – display ‘you can buy an car in loan’
>20,000 – display ‘ you can buy a house in loan’
>40,000 – display ‘ you can buy both car and house on loan’
<10,000 - display ‘earn more or save more for future plans’
SMT. NDJA Vivekananda Vidyalaya Sr. Sec School, Ch – 39
1. What is a string ? Declare a string and assign the value “God is Great”.
2. Write a function deleteChar() which takes two parameters one is a string and other is
a character. The function should create a new string after deleting all occurrences of
the character from the string and return the new string.
3. Explain the following string in-built functions ;
Count(), find(), index()
4. Explain String slicing with example for all parameters.
5. What is a function? List the different types of functions.
6. What is a module? What are the different ways in which a module can be imported?
7. Differentiate between local and global variable.
8. Consider the following string mySubject: (4)
i. print(mySubject[-7:-1])
ii. print(mySubject[::2])
iii. print(mySubject[len(mySubject)-1])
iv. print(2*mySubject)
v. print(mySubject[::-2])
vi. print(mySubject[:3] + mySubject[3:])
vii. print(mySubject.startswith('Comp'))
viii. print(mySubject.isalpha())
i. print(mySubject[-7:-1])
ii. print(mySubject[::2])
iii. print(mySubject[len(mySubject)-1])
iv. print(2*mySubject)
v. print(mySubject[::-2])
vi. print(mySubject[:3] + mySubject[3:])
vii. print(mySubject.startswith('Comp'))
viii. print(mySubject.isalpha())
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL, CHENNAI - 39
d. Write the Outputs of the MySQL queries(i) to(iv)based on the given above tables:
a. SELECT DISTINCT(CITY) FROM TRAINER WHERE SALARY>80000;
b. SELECT TID,COUNT(*),MAX(FEES) FROM COURSE GROUP BY TID HAVING
COUNT(*)>1;
c. SELECT T.TNAME,C.CNAME FROM TRAINER T,COURSE C WHERE T.TID=C.TID AND
T.FEES<10000;
SELECT COUNT(CITY),CITY FROM TRAINER GROUP BY CITY;
27 Write a method/function COUNTLINES_ET() in python to read lines from a text file
REPORT.TXT, and COUNT those lines which are starting either with ‘E’ or starting with
‘T’ and display the Total count separately.
For example: If REPORT.TXT consists of
“ENTRY LEVEL OF PROGRAMMING CAN BE LEARNED FROM PYTHON. ALSO, IT IS VERY
FLEXIBLE LANGUGAE. THIS WILL BE USEFUL FOR VARIETY OF USERS.”
Then, Output will be:
No. of Lines with E:1
No. of Lines with T : 1
OR
Write a method/function SHOW_TODO() in python to read contents from a textfile
ABC.TXT and display those lines which have occurrence of the word ‘‘TO’’ or ‘‘DO’’.
For example:
If the content of the fileis
“THIS IS IMPORTANT TO NOTE THAT SUCCESS IS
THE RESULT OF HARD WORK. WE ALL ARE
EXPECTEDTO DO HARDWORK.
AFTER ALL EXPERIENCE COMES FROM HARD WORK.”
The method/function should display:
THIS IS IMPORTANT TO NOTE THAT
WE ALL ARE EXPECTED TO DO HARD WORK.
Section-D
31 Aman is a Python programmer. He has written a code and created a binary file 4
record.dat with employeeid, ename and salary. The file contains 10 records.
Write the code to update a record based on the employee id entered by the user and
update the salary.
32 Consider the following dept and worker tables. Find outputs for sql queries (i) to (iii): 4
Table : DEPT
DCODE DEPARTMENT CITY
D01 MEDIA DELHI
D02 MARKETING DELHI
D03 INFRASTRUCTURE MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI
Table : WORKER
WNO NAME DOJ DOB GENDER DCODE
1001 George K 2013-09-01 1991-09-01 MALE D01
1002 Ryma Sen 2012-12-11 1990-12-15 FEMALE D03
1003 Mohitesh 2013-02-03 1987-09-04 MALE D05
1007 Anil Jha 2014-01-17 1984-10-19 MALE D04
1004 Manila Sahai 2012-12-09 1986-11-14 FEMALE D01
1005 S SAHAY 2013-11-18 1987-03-31 MALE D02
1006 Jaya Priya 2014-06-09 1985-06-23 FEMALE D05
29. Write a python script to accept 2 numbers and generate a random number between the two
numbers.
34. Write a python code to accept weight and height of a person and calculate the BMI (formula
weight(kg)/height(m)2) and display as per the following criteria :
BMI is <18.5 - underweight
35. List any five list functions and explain the same with example.
11. Arrange the following operators in the increasing order of their precedence:
**, * , +, <, not , or
12. List the logical operators.
13. How is = different from == ?
14. Expand a) ASCII b)FOSS
15. Classify the following into input devices and output devices :
Keyboard, Printer, Joystick, Mike, Speaker, Scanner
16. Define Cache Memory.
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
m) Both A and R are true and R is the correct explanation for A
n) Both A and R are true and R is not the correct explanation for A
o) A is True but R is False
p) A is false but R is True
17. Assertion : RAM is a volatile memory.
Reason : The contents of RAM is lost if the power is off.
18. Assertion : Mutable datatypes cannot be changed in place.
Reason : List is a mutable data type.
Section B (7x2=14)
19. How is a Microcontroller different Microprocessor?
20. Rewrite the following code after removing the errors :
n=int(input(“Enter a number:”)
if n>9 And n<100
print(“Two digit number’)
21. List the mutable data types and declare one variable for each mutable data type.
22. Prove using truth table A.(B+C)=AB+AC
23. Group the identifiers as valid and invalid :
a) AB_1 b) P@4 c) _1m d) 1_m
24. Write a ‘for’ loop to generate the following numbers : 2,8,13,18, 23, ….100
25. Evaluate the following statement:
a) 3+4-7*3 > 59 and 4+3-8 < 6*4//2 b) “All” and “best” or “last” not 0
Section C (5x3=15)
26. Identify the underlined tokens from the code given below :
m=int(input(“Enter a number”) #1
b=m+ 15 #2, 3,4
print(“Good”) #5, 6
Section D (2x4=8)
31.Define the following terms :
a) Operating system b) Language translators c) General Purpose Software d) Cache Memory
32. What are different types of errors encountered in the process of debugging? Give example for each.
Section E (3x5=15)
33.Convert the following numbers :
j) 341.67(8) to decimal
k) 579.23(10) to hexadecimal
l) 111011(2) to decimal
34. Write a python code to calculate the ticket amount for an event based on the following criteria:
Ticket Amount for adult is Rs.100 and for children in Rs.20. A discount of 10% is given if the total ticket
amount exceeds 500.
Or
Write a python code to calculate the total water bill of the month depending upon the number of units
consumed by the customer as per the following criteria:
For the first 100 unit @ 5 per unit
For the next 150 units @ 10 per unit
More than 250 units @ 20 per unit
Also add meter charges of 75 per month to calculate the total water bill.
35. What are the different type of operators in python. Explain with example.
SECTION A
1. State True or False 1
“Variable declaration is implicit in Python.”
2. Which of the following is an invalid datatype in Python? 1
(a) Set (b) None (c)Integer (d)Real
3. Given the following dictionaries 1
dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500, "Pass_Marks":165}
Which statement will merge the contents of both dictionaries?
a. dict_exam.update(dict_result)
b. dict_exam + dict_result
c. dict_exam.add(dict_result)
d. dict_exam.merge(dict_result)
4. Consider the given expression: 1
not True and False or True
Which of the following will be correct output if the given expression is
evaluated?
(a) True
(b) False
(c) NONE
(d) NULL
5. Select the correct output of the code: 1
a = "Year 2022 at All the best"
a = a.split('2')
b = a[0] + ". " + a[1] + ". " + a[3]
print (b)
(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5
10. Fill in the blank: 1
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17. Assertion (A):- If the arguments in function call statement match the 1
number and order of arguments as defined in the function definition,such
arguments are called positional arguments.
Reasoning (R):- During a function call, the argument list first contains
default argument(s) followed by positional argument(s).
18. Assertion (A): CSV (Comma Separated Values) is a file format for data 1
storage which looks like a text file.
Reason (R): The information is organized with one record on each line
and each field is separated by comma.
SECTION B
19. Rao has written a code to input a number and check whether it is 2
prime or not. His code is having errors. Rewrite the correct code and
underline the corrections made.
def prime():
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else:
print("Number is prime \n’)
20. Write a function countNow(PLACES) in Python, that takes the dictionary, 2
PLACES as an argument and displays the names (in uppercase)of the
places whose names are longer than 5 characters.
For example, Consider the following dictionary
PLACES={1:"Delhi",2:"London",3:"Paris",4:"New York",5:"Doha"}
The output should be:
LONDON
NEW YORK
OR
Write a function, lenWords(STRING), that takes a string as an argument
and returns a tuple containing length of each word of a string.
For example, if the string is "Come let us have some fun", the tuple will
have (4, 3, 2, 4, 4, 3)
21. (a) Given is a Python string declaration: 1
myexam="@@CBSE Examination 2022@@"
Write the output of: print(myexam[::-2])
(b) Write the output of the code given below:
my_dict = {"name": "Aman", "age": 26}
my_dict['age'] = 27 1
my_dict['address'] = "Delhi"
print(my_dict.items())
22. Explain the use of ‘Foreign Key’ in a Relational Database Management 2
System. Give example to support your answer.
23. Ms. Shalini has just created a table named “Employee” containing 2
columns Ename, Department and Salary.
After creating the table, she realized that she has forgotten to add a
primary key column in the table. Help her in writing an SQL command to
add a primary key column EmpId of integer type to the table Employee.
Thereafter, write the command to insert the following record in the table:
EmpId- 999
Ename- Shweta
Department: Production
Salary: 26900
OR
Zack is working in a database named SPORT, in which he has created a
table named “Sports” containing columns SportId, SportName,
no_of_players, and category. After creating the table, he realized that
the attribute, category has to be deleted from the table and a new
attribute TypeSport of data type string has to be added. This attribute
TypeSport cannot be left blank. Help Zack write the commands to
complete both the tasks.
24. Predict the output of the Python code given below:
def Diff(N1,N2):
if N1>N2:
return N1-N2
else:
return N2-N1
NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')
or
Predict the output of the Python code given below: 2
tuple1 = (11, 22, 33, 44, 55 ,66)
list1 =list(tuple1)
new_list = []
for i in list1:
if i%2==0:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
25. Differentiate between count() and count(*) functions in SQL with 2
appropriate example.
OR
Table: Bank_Account
ACode Name Type
A01 Amrita Savings
A02 Parthodas Current
A03 Miraben Current
Table: Branch 1+2
ACode City
A01 Delhi
A02 Mumbai
A01 Nagpur
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the 3
relations Teacher and Placement given below:
Table : Teacher
T_ID Name Age Department Date_of_join Salary Gen
der
1 Arunan 34 Computer Sc 2019-01-10 12000 M
2 Saman 31 History 2017-03-24 20000 F
3 Randeep 32 Mathematics 2020-12-12 30000 M
4 Samira 35 History 2018-07-01 40000 F
Table : Placement
P_ID Department Place
1 History Ahmedabad
2 Mathematics Jaipur
3 Computer Sc Nagpur
For example:
If L contains [12,4,0,11,0,56]
SECTION D
31 Vedansh is a Python programmer working in a school. For the
2+2
Annual Sports Event, he has created a csv file named Result.csv,
to store the results of students in different sports events. The
structure of Result.csv is :
[St_Id, St_Name, Game_Name, Result]
Where
St_Id is Student ID (integer)
ST_name is Student Name (string)
Game_Name is name of game in which student is
participating(string)
Result is result of the game whose value can be either 'Won',
'Lost' or 'Tie'
For efficiently maintaining data of the event, Vedansh wants to
write the following user defined functions:
Accept() – to accept a record from the user and add it to the file
Result.csv. The column headings should also be added on top of
the csv file.
wonCount() – to count the number of students
who have won any event.
As a Python expert, help him complete the task.
32. (a) Write the output of the code given below: 2+2
p=5
def sum(q,r=2):
global p
p=r+q**2
print(p, end= '#')
a=10
b=5
sum(a,b)
sum(r=5,q=1)
(b) What is the difference between mutable and
immutable data types.
OR
(a) Predict the output of the code given below:
s="welcome2cs"
n =
len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m +
s[i].lower()
else:
m = m +'&'
print(m)
b) What is the difference between ‘is’ and ‘in’ operator?
SECTION - E
33 (i) Differentiate between r+ and w+ file modes in Python. 2+3=5
(ii) Consider a file, SPORT.DAT, containing records of the following structure:
[SportName, TeamName, No_Players]
Write a function, copyData(), that reads contents from the file SPORT.DAT and
copies the records with Sport name as “Basket Ball” to the file named BASKET.DAT.
The function should return the total number of records copied to the file
BASKET.DAT.
OR
(i) How are text files different from binary files?
(ii) A Binary file, CINEMA.DAT has the following structure:
{MNO:[MNAME, MTYPE]}
Where
MNO – Movie Number
MNAME – Movie Name
MTYPE is Movie Type
Write a user defined function, findType(mtype), that accepts mtype as parameter
and displays all the records from the binary file CINEMA.DAT, that have the value of
Movie Type as mtype.
34 Navdeep creates a table RESULT with a set of records to maintain the marks
secured by students in Sem 1, Sem2, Sem3 and their division. After creation of the
table, he has entered data of 7 students in the table.
ROLL_NO SNAME SEM1 SEM2 SEM3 DIVISION
101 KARAN 366 410 402 I
102 NAMAN 300 350 325 I
103 ISHA 400 410 415 I
104 RENU 350 357 415 I
105 ARPIT 100 75 178 IV
106 SABINA 100 205 217 II
107 NEELAM 470 450 471 I
import #Statement 1
def update_data():
rec={}
fin=open("record.dat","rb")
fout=open(" ") #Statement 2
found=False
eid=int(input("Enter employee id to update
their salary :: "))
while True:
try:
rec= #Statement 3
if rec["Employee id"]==eid:
found=True
rec["Salary"]=int(input("Enter new salary
:: "))
pickle. #Statement 4
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print("The salary of employee id ",eid," has
been updated.")
else:
print("No employee with such id is not found")
fin.close()
fout.close()
1
(i) Which module should be imported in the program?(statement1)
(ii) Write the correct statement required to open a temporary file 1
named temp.dat. (Statement 2)
(iii) Which statement should Aman fill in Statement 3 to read the 2
data from the binary file, record.dat and in Statement 4 to
write the updated data in the file, temp.dat?
1
(iv) What is the datatype of the object ‘found’ and ‘rec’?
To accept length, breadth and height of a cuboid and print its volume (lxbxh) and Total Surface
area 2 (lb+bh+lh). (4)
To accept length, breadth and height of a cuboid and print its volume (lxbxh) and Total Surface
area 2 (lb+bh+lh). (4)
6. Display the product name which starts with the alphabet ‘S’.
7. List the Product names without repetition
8. Display product details whose price is more than 100.
6. Display the product name which starts with the alphabet ‘S’.
7. List the Product names without repetition
8. Display product details whose price is more than 100.
3. Write the 12 modes of file opening, its description and file offset position.
3. Write the 12 modes of file opening, its description and file offset position.
4. Write the file mode that will be used for opening the following files. Also, write the Python
statements to open the following files:
a) a text file “example.txt” in both read and write mode
b) a binary file “bfile.dat” in write mode
c) a text file “try.txt” in append and read mode
d) a binary file “btry.dat” in read only mode
e) to create a text file “log.txt” to write contents
5. When are the following built-inexceptions raised? Give examples to support your answers.
a) ValueError
b) IndexError
c) NameError
d) ZeroDivisionError
e) TypeError
4. Write the file mode that will be used for opening the following files. Also, write the Python
statements to open the following files:
a) a text file “example.txt” in both read and write mode
b) a binary file “bfile.dat” in write mode
c) a text file “try.txt” in append and read mode
d) a binary file “btry.dat” in read only mode
e) to create a text file “log.txt” to write contents
5. When are the following built-inexceptions raised? Give examples to support your answers.
a) ValueError
b) IndexError
c) NameError
d) ZeroDivisionError
e) TypeError
SMT. NDJA Vivekananda Vidyalaya Sr. Sec School, Ch – 39
1. What is a string ? Declare a string and assign the value “God is Great”.
2. Write a function deleteChar() which takes two parameters one is a string and other is
a character. The function should create a new string after deleting all occurrences of
the character from the string and return the new string.
3. Explain the following string in-built functions ;
Count(), find(), index()
4. Explain String slicing with example for all parameters.
5. What is a function? List the different types of functions.
6. What is a module? What are the different ways in which a module can be imported?
7. Differentiate between local and global variable.
8. Consider the following string mySubject: (4)
i. print(mySubject[-7:-1])
ii. print(mySubject[::2])
iii. print(mySubject[len(mySubject)-1])
iv. print(2*mySubject)
v. print(mySubject[::-2])
vi. print(mySubject[:3] + mySubject[3:])
vii. print(mySubject.startswith('Comp'))
viii. print(mySubject.isalpha())
i. print(mySubject[-7:-1])
ii. print(mySubject[::2])
iii. print(mySubject[len(mySubject)-1])
iv. print(2*mySubject)
v. print(mySubject[::-2])
vi. print(mySubject[:3] + mySubject[3:])
vii. print(mySubject.startswith('Comp'))
viii. print(mySubject.isalpha())
SMT. NDJA Vivekananda VidyalayaSr. SecSchool, Ch – 39
Consider the following tables Employee and salary. Write SQL commands for the
statements (i) to (xiv) and give outputs for SQL queries (xv) to (xx)
Table : Employee
1.Create the table Employee and Table Salary with necessary constraints.(5)
2. Consider the following tables Employee and salary. Write SQL commands for the
statements (i) to (xiv) and give outputs for SQL queries (xv) to (xx)
(ii) To list the names of those employees only whose basic is greater than 3000.
(iv) To print the net salary from salary table where as net salary is calculated as
basic+da+hra+bonus
(ix) Display the names of employees whose name starts with ‘s’
(xi) Display no. of employees, maximum basic and minimum basic for deptid 101
(xii) Display the name of the person who gets the maximum Basic
(xv) Select name from employee where eid=(select eid from salary where basic=
(select max(basic) from salary));
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL
I MID TERM EXAMINATION – 2022-2023
Std : XI Max Marks : 35
Subject : Computer Science Time : 1 ½ hrs
I. Objective type questions : (10 x 1 =10)
1. Who developed python?
2. List the two Boolean values.
3. List the mutable data types.
4. What are the 2 looping structures available in python?
5. List the rules of naming identifiers.
6. What the logical operators? List them.
7. Name the sequence data types in python.
8. What are the decision making statements in python?
9. What is the data type of the input() function?
10. How are comments included in the python code?
II. Case based question (4 x 1 =4)
11. Observer the following code and identify the tokens (any 4) that are underlined :
Python code to find the eligibility to vote or not :
Age=int(input(“Enter your age”)) - (1)
if Age>=18: - (2)
print(“Eligible to vote”) - (3)
else: - (4)
print(“Not eligible to vote”) - (5)
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL
I MID TERM EXAMINATION – 2022-2023
Std : XI Max Marks : 35
Subject : Computer Science Time : 1 ½ hrs
I. Objective type questions : (10 x 1 =10)
1. Who developed python?
2. List the two Boolean values.
3. List the mutable data types.
4. What are the 2 looping structures available in python?
5. List the rules of naming identifiers.
6. What the logical operators? List them.
7. Name the sequence data types in python.
8. What are the decision making statements in python?
9. What is the data type of the input() function?
10. How are comments included in the python code?
II. Case based question (4 x 1 =4)
11. Observer the following code and identify the tokens (any 4) that are underlined :
Python code to find the eligibility to vote or not :
Age=int(input(“Enter your age”)) - (1)
if Age>=18: - (2)
print(“Eligible to vote”) - (3)
else: - (4)
print(“Not eligible to vote”) - (5)
III. Very Short Answer (2 x 2 =4)
12. List all the relational operators with its meaning.
13. Evaluate the following (show the steps):
i) 12*3+4-12/3
ii) 25 and 13 or 11 and not 0
PART A
Section I (15x1=15)
Select the most appropriate option out of the options given for each question. Attempt any 15
questions from questions no. 1 to 21.
1. Name the Python Library modules which need to be imported to invoke the following
functions : (i) dump () (ii) factorial()
2. Write a statement in Python to open a text file CONTENT.TXT so that new contents can be
written in it.
3. Find the invalid identifier from the following
a) MyName b) True c) 2ndName d) My_Name
4. Given the lists L=[1,3,6,82,5,7,11,92] , write the output of print(L[2:5])
5. Write the full form of CSV.
6. Identify the valid arithmetic operator in Python from the following.
a) ? b) < c) ** d) and
7. What will be the output for the following python statement?
D={“AMIT”:90,”RESHMA”:96,”SUKHBIR”:92,”JOHN”:95}
print(“JOHN” in D, 90 in D,sept=”#”)
8. Dictionaries are also called as _____
9. What is the significance of pass statement?
10. Give a dictionary D={1:”one”}, write a statement to add the pair (2,”Two”).
11. What is a docstring?
12. What does the S contain for the following statement?
S=[a-1 for a in range(20,5,-2)]
13. Find the output of the following statement:
A=[[1,2,3,4,5],[6,7,8,9]]
print(A[1][2], A[2][1])
14. In the following declaration what is the significance of *
defabc(*a):
print(a)
15. What is the output of the following statement?
d1={1:2,2:3,3:4}
d2={1:2,2:3,3:4}
d1 is d2
16. Which statement among s1 and s2 will raise an error? Why?
a=[1,2,(3,4)]
b=(1,2,[3,4])
a[2][0]=30 #s1
b[2][0]=30 #s2
17. Write a python statement to check whether the variable ‘m’ is a 2 digit positive whole
number.
18. Declare a tuple containing the names of five states of India.
19. Find the output of the following statement :
S=”all are welcome”
print( S[-1:-10])
20. Find the module to be imported for the following functions:
randint() cos()
21.Which output lines of the following program will print the same results?
tup1 = (10, 20, 30, 40, 50, 60, 70, 80, 90)
print(tup1[5:-1]) # 1
print(tup1[5]) # 2
print(tup1[5:]) # 3
print(tup1[-4:8]) # 4
Section II (2 x 4 =8)
Both the case study-based questions are compulsory. Attempt any 4 sub-parts from each
question. Each question carries 1 mark.
22. Radha Shah is a programmer, who has recently been given a task to write a python code to
perform the following CSV file operations with the help of two user defined
functions/modules:
a. CSVOpen() : to create a CSV file called BOOKS.CSV in append mode containing information of
books – Title, Author and Price.
b. CSVRead() : to display the records from the CSV file called BOOKS.CSV where the field title
starts with 'R'. She has succeeded in writing partial code and has missed out certain
statements, so she has left certain queries in comment lines
You as an expert of Python have to provide the missing statements and other related queries
based on the following code of Radha. Answer any four questions (out of five) from the below
mentioned questions.
i. Write the appropriate mode in which the file is to be opened in append mode
(Statement 1)
ii. Write the statement to create a csv writer object in Statement 2.
iii. Write Statement 3 to write the names of the column headings in the CSV file,
BOOKS.CSV.
iv. Write statement to read a csv file in Statement 4.
v. Fill in the appropriate statement to check the field Title starting with ‘R’ for Statement 5
in the above program.
23. Your teacher has given you a method/function FilterWords() in python which read lines
from a text file NewsLetter.TXT, and display those words, which are lesser than 4 characters.
Your teachers intentionally kept few blanks in between the code and asked you to fill the
blanks so that the code will run to find desired result. Do the needful with the following python
code.
i. Write mode of opening the file in statement-1?
ii. Fill in the blank in statement-2 to read the data from the file.
iii. Fill in the blank in statement-3 to break the data word by word.
iv. Fill in the blank in statement-4, which display the word having lesser than 4 characters.
v. Fill in the blank in Statement-5 to close the file.
Part – B
Section – 1: (10 x 2 =20)
24 Which of the following are valid operators in Python ?
(i) += (ii) ^ (iii) in (iv) && (v) between (vi) */ (vii) is (viii) like
25. Rewrite the following code in Python after removing all syntax error(s). Underline each
correction done in the code.
26. Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.
27. Find and write the output of the following Python code :
28. Write a method/function BIGWORDS() in Python to read contents from a text file
CODE.TXT, to count and display the occurrence of those words, which are having 5 or more
alphabets.
For example : If the content of the file is
ME AND MY FRIENDS ENSURE SAFETY AND SECURITY OF EVERYONE
The method/function should display Count of big words is 5
Or
Write a method/function BIGLINES() in Python to read lines from a text file CONTENT.TXT, and
display those lines, which are bigger than 20 characters.
For example : If the content of the file is :
Stay positive and happy
Work hard and dont give up hope
Be open to criticism and keep learning
Surround yourself with happy, warm and genuine people
The method/function should display :
Be open to criticism and keep learning
Surround yourself with happy, warm and genuine people
29.
30. Find and write the output of the following Python code :
31. Find and write the output of the following python code :
33. 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 maximum values that can be
assigned to each of the variables Lower and Upper.
Section – II (4 x 3 =12)
35. Write a Python method/function SwitchOver(Val) to swap the even and odd positions of
the values in the list Val.
Note : Assuming that the list has even number of values in it.
For example : If the list Numbers contain [25,17,19,13,12,15] After swapping the list content
should be displayed as [17,25,13,19,15,12]
or
Write a Python method/function Count(Start,End,Step) to display natural numbers from Start
to End in equal intervals of Step and the sum of all the number.
For example : If the values of Start as 14, End as 35 and Step as 6 The method should be
displayed as 14, 20, 26, 32 Sum of all numbers : 92
36. Find and write the output of the following python code :
40. Write a function to find and display the number of words, lower case characters, upper
case characters, vowels and digits in the text file notes.txt.
SMT NDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL, VYASARPADI, CHENNAI -39
PERIODIC TEST – JULY – 2022-2023
Std : XII Marks : 25
Subject : Computer Science Time : 40 min
1. Find the output of the following program segments:( 6 x 2 =12)
(i) (ii) (iii)
a = 110 for i in range(20,30,2): country = 'INDIA'
while a > 100: print(i) for i in country:
print(a) print (i.lower())
a -= 2
2. Write python code to find prime numbers between 2 to 50 using nested for loops.(4)
2. Write python code to find prime numbers between 2 to 50 using nested for loops.(4)
4. Write a python code to accept the annual salary and print the loan amount eligible
based on the following condition (5)
5. Evaluate:
1. 20 % 4 ** 2 // 7 + 12 / 3
2. 20%6< 5 or 25/5 == 5 and not 11>=11
3. 2+9*((3*12)-8)/10
4. “False”==False
5. 13>17<11
5. Evaluate:
1. 20 % 4 ** 2 // 7 + 12 / 3
2. 20%6< 5 or 25/5 == 5 and not 11>=11
3. 2+9*((3*12)-8)/10
4. “False”==False
5. 13>17<11
6. 18 % 4 ** 3 // 7 + 9 /3
7. 22%4 < 5 or 25/5 == 5 and not 12 >=9
8. 2+9*((3*12)-8)/10
9. ‘Bye’== “BYE”
1. 18 % 4 ** 3 // 7 + 9 /3
2. 22%4 < 5 or 25/5 == 5 and not 12 >=9
3. 2+9*((3*12)-8)/10
4. ‘Bye’== “BYE”
10. 18 % 4 ** 3 // 7 + 9 /3
11. 22%4 < 5 or 25/5 == 5 and not 12 >=9
12. 2+9*((3*12)-8)/10
13. ‘Bye’== “BYE”
5. 18 % 4 ** 3 // 7 + 9 /3
6. 22%4 < 5 or 25/5 == 5 and not 12 >=9
7. 2+9*((3*12)-8)/10
8. ‘Bye’== “BYE”
3. Write the 12 modes of file opening, its description and file offset position.
3. Write the 12 modes of file opening, its description and file offset position.
4. Write the file mode that will be used for opening thefollowing files. Also, write the
Python statements to openthe following files:
a) a text file “example.txt” in both read and write mode
b) a binary file “bfile.dat” in write mode
c) a text file “try.txt” in append and read mode
d) a binary file “btry.dat” in read only mode
e) acsv file “names.csv” to search for a name.
5. Consider a csv file stock.csv containing (product id, description, rate) write function
for the following :
a) Add a new product to stock.csv
b) Display products whose rate is more then 50
4. Write the file mode that will be used for opening thefollowing files. Also, write the
Python statements to openthe following files:
a) a text file “example.txt” in both read and write mode
b) a binary file “bfile.dat” in write mode
c) a text file “try.txt” in append and read mode
d) a binary file “btry.dat” in read only mode
e) acsv file “names.csv” to search for a name.
5. Consider a csv file stock.csv containing (product id, description, rate) write function
for the following :
a) Add a new product to stock.csv
b) Display products whose rate is more then 50
SNDJA VIVEKANANDA VIDYALAYA SR SEC SCHOOL
– 2022-2023
Std : XII Max Marks :
70
Subject : Computer Science Time : 3 hrs
General Instructions :
(i) This question paper contains two parts Part A and B. Each part is compulsory.
(ii) Both Part A and Part B have choices.
(iii) Part A has two sections :
a. Section I is short answer questions, to be answered in one word or one line.
b. Section II has two case study-based questions. Each case study has 5 case-based
subparts. An examinee is to attempt any 4 out of the 5 subparts.
(iv) Part B is Descriptive Paper.
(v) Part B has three sections :
a. Section I is short answer questions of 2 marks each in which two questions have
internal options.
b. Section II is long answer questions of 3 marks each in which two questions have
internal options.
c. Section III is very long answer questions of 5 marks each in which one question
has an internal option.
(vi) All programming questions are to be answered using Python Language only.
PART A
Section I (15x1=15)
Select the most appropriate option out of the options given for each question. Attempt
any 15 questions from questions no. 1 to 21.
Section II (2 x 4 =8)
Both the case study-based questions are compulsory. Attempt any 4 sub-parts from
each question. Each question carries 1 mark.
Part – B
Section – 1: (10 x 2 =20)
Section – II (4 x 3 =12
BLUE PRINT