Students can Download Tamil Nadu 12th Computer Science Model Question Paper 4 English Medium Pdf, Tamil Nadu 12th Computer Science Model Question Papers helps you to revise the complete Tamilnadu State Board New Syllabus, helps students complete homework assignments and to score high marks in board exams.
TN State Board 12th Computer Sceince Model Question Paper 4 English Medium
General Instructions:
- The question paper comprises of four parts.
- You are to attempt all the parts. An internal choice of questions is provided wherever applicable.
- All questions of Part I, II, III and IV are to be attempted separately.
- Question numbers 1 to 15 in Part I are Multiple Choice Questions of one mark each.
These are to be answered by choosing the most suitable answer from the given four alternatives and writing the option code and the corresponding answer - Question numbers 16 to 24 in Part II are two-mark questions. These are to be answered in about one or two sentences.
- Question numbers 25 to 33 in Part III are three-mark questions. These are to be answered in about three to five short sentences.
- Question numbers 34 to 38 in Part IV are five-mark questions. These are to be answered in detail Draw diagrams wherever necessary.
Time: 3 Hours
Maximum Marks: 70
PART – 1
Choose the correct answer. Answer all the questions: [15 × 1 = 15]
Question 1.
Why is the function random( ) is a impure function?
(a) It gives different outputs for same function call
(b) It gives different outputs when 0 is given
(c) It will not give different output
Answer:
(a) It gives different outputs for same function call
Question 2.
The process of subdividing a computer program into separate sub-programs is called ……………….
(a) Procedural Programming
(b) Modular programming
(c) Event Driven Programming
(d) Object oriented Programming
Answer:
(b) Modular programming
Question 3.
If a problem can be broken into subproblems which are reused several times, the problem possesses which property?
(a) Overlapping subproblems
(b) Optimal substructure
(c) Memoization
(d) Greedy
Answer:
(a) Overlapping subproblems
Question 4.
Ox represents ………………. integer.
(a) Binary
(b) Hexadecimal
(c) Decimal
(d) Octal
Answer:
(b) Hexadecimal
Question 5.
Which amongst this is not a Jump Statement?
(a) For
(b) Goto
(c) Continue
(d) Break
Answer:
(a) For
Question 6.
Which is the optional part in range?
(a) Start
(b) Stop
(c) Step
(d) Iner
Answer:
(c) Step
Question 7.
Which function is used to change all occurances of a particular character in a string?
(a) Replace ( )
(b) Change ( )
(c) Edit ( )
(d) Append( )
Answer:
(a) Replace ( )
Question 8.
The default value of stride is …………………
(a) 0
(b) 1
(c) n
(d) n-1
Answer:
(b) 1
Question 9.
The mixed collection of elements are called ………………
(a) List
(b) Tuples
(c) Sets
(d) Dictionary
Answer:
(d) Dictionary
Question 10.
Class members are accessed through ……………. operators
(a) &
(b) .
(c) #
(d) %
Answer:
(b) .
Question 11.
Find the wrong pair.
(a) Union U
(b) Project π
(c) Select σ
(d) Cartesian product P
Answer:
(d) Cartesian product P
Question 12.
The update command specifies the rows to be changed using …………………
(a) Where
(b) Why
(c) What
(d) How
Answer:
(a) Where
Question 13.
In open command, file name can be represented in ………………..
(a) ” ”
(b) ‘ ‘
(c) $
(d) both (a) & (b)
Answer:
(d) both (a) & (b)
Question 14.
Which command of OS module executes the exe files?
(a) Run
(b) System ( )
(c) Main
(d) Name
Answer:
(b) System ( )
Question 15.
The SQL commands have to be defined with ………………… quotes.
(a) Single
(b) Double
(c) Triple
(d) No quote
Answer:
(c) Triple
PART – II
Answer any six questions. Question No. 21 is compulsory. [6 × 2 = 12]
Question 16.
Write the inference you get from X:=78 ?
Answer:
Value 78 being bound to the name X.
Question 17.
Write note on Definitions?
Answer:
Definitions bind values to names, Definitions are not expressions, Definitions are distinct syntactic blocks. Definitions can have expressions nested inside them, and vice-versa.
Question 18.
What is a Pair? Give an example?
Answer:
Pair is a compound structure which is made up of list or Tuple. lst[(0, 10), (1,20)] -where
Any way of bundling two values together into one can be considered as a pair. Lists are a common method to do so. Therefore List can be called as Pairs.
Question 19.
Define fixed part in the space complexity?
Answer:
A fixed part is defined as the total space required to store certain data and variables for an algorithm. For example, simple variables and constants used in an algorithm.
Question 20.
Name the different types of alternative statements in Python?
Answer:
Python provides the following types of alternative or branching statements:
- Simple if statement
- if..else statement
- if.elif statement
Question 21.
Find output:
- abs (-25 + 12.0)
- abs (-3.2).
Answer:
Output:
- 13
- 3.2
Question 22.
Give the syntax for passing parameters in functions?
Answer:
Parameters or arguments can be passed to functions.
Syntax:
def function_name (parameters) separated by comma):
Question 23.
Differentiate del with remove( ) function of List?
Answer:
There are two ways to delete an element from a list viz. del statement and remove() function, del statement is used to delete known elements whereas remove() function is used to delete elements of a list if its index is unknown. The del statement can also be used to delete entire list.
Question 24.
What is instantiation?
Answer:
Once a class is created, next you should create an object or instance of that class. The process of creating object is called as “Class Instantiation”.
Syntax:
objectname = class_name( )
PART – III
Answer any six questions. Question No. 29 is compulsory. [6 × 3 = 18]
Question 25.
What are class members? How do you define it?
Answer:
In Python, a class is defined by using the keyword class. Every class has a unique name followed by a colon (:).
Syntax:
class class name:
statement_1
statement_2
statement
…….
……
statement_n
Where, statement in a class definition may be a variable declaration, decision control, loop or even a function definition. Variables defined inside a class are called as “Class Variable” and functions are called as “Methods”. Class variable and methods are together known as members of the class. The class members should be accessed through objects or instance of class. A class can be defined anywhere in a Python program.
Example: Program to define a class
class Sample:
x, y = 10, 20 # class variables
In the above code, name of the class is Sample and it has two variables x and y having the initial value 10 and 20 respectively. To access the values defined inside the class, you need an object or instance of the class.
Question 26.
What is meant by data model?
Answer:
- A data model describes how the data can be represented and accessed from a software after complete implementation
- It is a simple abstraction of complex real world data gathering environment.
- The main purpose of data model is to give an idea as how the final system or software will look like after development is completed.
Question 27.
Write the use of Savepoint command with an example?
Answer:
SAVEPOINT command:
The SAVEPOINT command is used to temporarily save a transaction so that you can rollback to the point whenever required. The different states of our table can be saved at anytime using different names and the rollback to that state can be done using the ROLLBACK command.
SAVEPOINT savepoint_name;
UPDATE Student SET Name = ‘Mini ’ WHERE Admno=105;
SAVEPOINT A;
Question 28.
Write a program to count the number of male and female students from the student table?
Example:
Answer:
import sqlite3
connection= sqlite3.connect(“Academy.db”)
cursor = connection. cursor( )
cursor. execute(” SELECT gender,count(gender) FROM student Group BY gender”)
result = cursor. fetchall( )
print(*result,sep=”\n”)
Output:
(‘F’, 2)
(‘M’, 5)
Question 29.
What will be the output of the given python program?
Answer:
str1 = “welcome”
str2 = “to school”
str3 = str 1 [: 2]+str2 [len(str2)-2:]
print(str3)
Output:
weool
Question 30.
Write any 6 delimiters in python?
Answer:
Question 31.
What are string literals? Explain?
Answer:
In Python a string literal is a sequence of characters surrounded by quotes. Python supports single, double and triple quotes for a string. A character literal is a single character surrounded by single or double quotes. The value with triple-quote is used to give multi-line string literal.
strings = “This is Python”
char = “C”
multilinestr = ‘”This is a multiline string with more than one line code.'”
Question 32.
Give an example program for Ternary operator?
Answer:
# Program to demonstrate conditional operator
a, b = 30, 20
# Copy value of a in min if a < b else copy b
min = a if a < b else b
print (“The Minimum of A and B is “,min)
# End of the Program
Output:
The Minimum of A and B is 20
Question 33.
Write a note about count( ) function in python?
Answer:
PART – IV
Answer all the questions. [5 × 5 = 25]
Question 34(a).
Write the Output for the given program?
Answer:
[OR]
(b) Write a python program to check whether the given number is odd or even?
Example: #Program to check if the accepted number odd or even?
Answer:
a = int(input(“Enter any number :”))
if a%2==0:
print (a, ” is an even number”)
else:
print (a, ” is an odd number”)
Output 1:
Enter any number :56 56 is an even number
Output 2:
Enter any number :67 67 is an odd number
Question 35(a).
Explain while loop with sample program?
Answer:
Syntax:
while <condition>:
statements block 1
[else:
statements block 2]
In the while loop, the condition is any valid Boolean expression returning True or False. The else part of while is optional part of while. The statements blockl is kept executed till the condition is True. If the else part is written, it is executed when the condition is tested False. Recall while loop belongs to entry check loop type, that is it is not executed even once if the condition is tested False in the beginning.
Example: program to illustrate the use of while loop – to print all numbers from 10 to 15
Output:
10 11 12 13 14 15
[OR]
(b) Explain the following built-in functions?
Answer:
Question 36 (a).
Evaluate the following function and write the output?
- forinat(66, ‘c’)
- format(10, ‘x’)
- format(10, ‘X’)
- format(0bll0, ‘d’)
- format(0xa, ‘d’)
Answer:
- B
- a
- A
- 6
- 10
[OR]
(b) Write a program to swap two strings?
Answer:
print(“Enter ‘x’ for exit.”)
string 1 = input(“Enter first string : “)
if string 1 = = ‘x’: exit));
else:
string2 = input(“Enter second string : “)
print(” \n Both strings before swap : “)
print(“First string = ” , string1)
print(” Second string = ” , string2)
temp = string1 string1 = string2
string2 = temp
print(“\n Both strings after swap : “)
print(“First string = ” , string1)
print(” Second string = “, string2)
Output:
Enter ‘X’ for exit
Enter first string : code
Enter second string : python
Both strings before swap:
First string = code Second string = python Both strings after swap:
First string = python Second string = code
Question 37 (a).
Write a program to create a list of numbers in the range 1 to 20. Then delete all the numbers from the list that are divisible by 3?
Answer:
num = [ ]
for x in range(1, 21):
num.append(x)
print(“The list of numbers from 1 to 20 =”, num) for index, i in enumerate(num):
if(i % 3 == 0)
del num[index]
print(“The list after deleting numbers”, num)
Output:
The list of numbers from 1 to 20 = [1,2,3,4… 20]
The list after deleting numbers[l, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20]
[OR]
(b) Write a program using class to store name and marks of students in list and print total marks?
Answer:
class stud:
def_init_(self):
self.name=” ”
self.m1=0
self.m2=0
self.tot=0
def gdata(self):
self.name = input(“Enter your name”)
self.m1 = int(input(“Enter marks 1”))
self.m2 = int(input(“Enter marks2”))
self, tot = self.m1 + self.m2
def disp(self):
print(self.name)
print(self.m1)
print(self.m2)
print(self.tot)
mlist = [ ]
st = stud( )
st.gdata( )
mlist.append(st)
for x in mlist:
x.disp( )
Output:
Question 38.
Write the different types of constraints and their functions?
Answer:
Constraints ensure database integrity, therefore known as database integrity constraints.
(I) Unique Constraint:
This constraint ensures that no two rows have the same value in the specified columns. For example UNIQUE constraint applied on Admno of student table ensures that no two students have the same admission number and the constraint can be used as:
CREATE TABLE Student
(
Admno integer NOT NULL UNIQUE → Unique constraint
Name char (20) NOT NULL,
Gender char (1),
Age integer,
Place char (10),
);
The UNIQUE constraint can be applied only to fields that have also been declared as NOT NULL.
When two constraints are applied on a single field, it is known as multiple constraints. In the above Multiple constraints NOT NULL and UNIQUE are applied on a single field Admno, the constraints are separated by a space and at the end of the field definition a comma(,) is added. By adding these two constraints the field Admno must take some value i.e. will not be NULL and should not be duplicated.
(II) Primary Key Constraint:
This constraint declares a field as a Primary key which helps to uniquely identify a record. It is similar to unique constraint except that only one field of a table can be set as primary key. The primary key does not allow NULL values and therefore a field declared as primary key must have the NOT NULL constraint.
Example showing Primary Key Constraint in the student table:
CREATE TABLE Student
(
Admno integer NOT NULL PRIMARY KEY, → Primary Key constraint
Name char(20)NOT NULL,
Gender char(I),
Age integer,
Place char(10),
);
In the above example the Admno field has been set as primary key and therefore will help us to uniquely identify a record, it is also set NOT NULL, therefore this field value cannot be empty,
(III) DEFAULT Constraint:
The DEFA ULT constraint is used to assign a default value for the field. When no value is given for the specified field having DEFA ULT constraint, automatically the default value will be assigned to the field.
Example showing DEFAULT Constraint in the student table:
CREATE TABLE Student
(
Admno integer NOT NULL PRIMARY KEY,
Name char(20) NOT NULL,
Gender char(1),
Age integer DEFAULT = “17”, → Default Constraint Place char(10),
); –
In the above example the “Age” field is assigned a default value of 17, therefore when no
value is entered in age by the user, it automatically assigns 17 to Age.
(IV) Check Constraint:
This constraint helps to set a limit value placed for a field. When we define a check constraint on a single column, it allows only the restricted values on that field.
Example showing check constraint in the student table:
CREATE TABLE Student
(
Admno integer NOT NULL PRIMARY KEY
Name char(20)NOT NULL,
Gender char(1),
Age integer (CHECK<=19), → Check Constraint Place char(10),
);
In the above example the check constraint is set to Age field where the value of Age must be less than or equal to 19.
Note:
The check constraint may use relational and logical operators for condition.
(V) TABLE CONSTRAINT:
When the constraint is applied to a group of fields of the table, it is known as Table constraint. The table constraint is normally given at the end of the table definition. Let us take a new table namely Student 1 with the following fields Admno, Firstname, Lastname, Gender, Age, Place:
CREATE TABLE Student 1
(
Admno integer NOT NULL,
Firstname char(20),
Lastname char(20),
Gender char(1),
Age integer,
Place char(10),
PRIMARY KEY (Firstname, Lastname) → Table constraint
);
In the above example, the two fields, Firstname and Lastname are defined as Primary key which is a Table constraint.
[OR]
(b) Write a C++ program to print boundary elements of a matrix and name the file as Border.cpp. Write a python program to execute the Border.cpp?
Answer:
Select File → New in Notepad and type the C++ program.
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX = 100;
void printBoundary(int a[ ][max], int m, int n)
{
for (int i=0; i < m; i++)
{
for(int j=0; j < n; j++)
{
if(i= =0 || j= =0 || i= =n-l || j= =n-1)
cout<<a[i][j] <<” ”
else
cout« ” ”
cout« ” ”
}
cout<<” \n”;
}}
int main( )
{
inta[4][MAX] = { {1 ,2, 3, 4}, {5, 6, 7, 8}, {1, 2, 3, 4}, {5, 6, 7, 8}};
print Boundary(a, 4, 4);
return 0;
}
save it as Border.cpp
open a New notepad file and type the python program to execute border.cpp
#python border.py -i border.cpp
import sys,os,getopt
def main(argv):
cppfile =” exe_file =”
opts, args = getopt.getopt(argv, “i:”,[‘ifile=’])
for o, a in opts: if o in(“-i”, “-ifile”):
cppfile =a+ ‘.cpp’
exefile = a+ ‘.exe’
run(cpp file, exe file)
def run(cpp_file, exe file):
print(“Compiling” + cppfile) os.system(‘g++’+ cpp file + ‘-o ‘+ exe file)
print(“Running” + exefile)
print(” “)
print
os.system(exe_file)
print
if name =’ main ‘:
main(sys.argv[l:])
Output: