12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications மின்னணு தரவு பரிமாற்றம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிக பாதுகாப்பு அமைப்புகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின்னணு செலுத்தல் முறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications திறந்த மூல கருத்துருக்கள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு வடமிடல் Sample Question Papers Study Material - QB365 Set A

Published on: 03/02/2021
12th Standard Computer Science English Medium Python Classes and Objects Reduced Syllabus Important Questions With Answer Key 2021
Download Tamil Nadu 12th Standard Computer Science question papers, model tests, one-mark questions, important questions, and public exam papers in PDF format. Free study materials and answer keys for TN State Board students.
Questions + Answers key
Take MCQ Computer Science Test

1.
A variable prefixed with __________ become private in nature.
double underscore
double colon
double dot
double hyphen
2.
When class variable declared within class, methods must be prefixed by the ________ and _______________
classnam, :
classname,.
:, classname
classname, objectname
3.
In Python, the class method must name the first argument named as ___________
this
new
self
var
4.
The ____ of the class should be accessed through instance of a class.
Objects
Members
Functions
Tuples
5.
In Python, a class is defined by using the _______ class.
Operator
Identifier
Object
Keyword
6.
______ and_____ are the key features of object oriented programming.
List and tuples
Set and dictionary
Classes and objects
Variables and methods
7.
Which of the following variables can be accessed only within the class?
Protected
Public
Private
None of these
8.
Which of the following is automatically executed when an object of a class is created?
constructor
destructor
class
members
9.
Which position of the argument named self in python class method?
First
Second
Third
Last
10.
Write the output for the following
class test
x, y = 10,5
s=test ()
print (s. x + s. y)
10
5
15
105
11.
Functions of the class are called as
Methods
Members
Variables
Loog
12.
Which of the following is the output of the following program?
class Student:
def __init__(self, name):
self.name=name
print (self.name)
S=Student(“Tamil”)
Error
Tamil
name
self
13.
Which of the following class declaration is correct?
class class_name
class class_name<>
class class_name:
class class_name[ ]
14.
Which of the following method is used as destructor?
__init__( )
__dest__( )
__rem__( )
__del__( )
15.
Which of the following are the key features of an Object Oriented Programming language?
Constructor and Classes
Constructor and Object
Classes and Objects
Constructor and Destructor
16.
Write a note on public and private data members of python class.
17.
Explain the working of the following program
class Sample:
num=0
def _init_(self) var):
Sample.num+= 1
self.var=var
print("The object value is = ", var)
print("The count of object created Sample.num) =",
S1=Sample(15)
S2=Sample(35)
S3=Sample(45)
18.
Write a program in python that illustrate the use of constructor.
19.
Differentiate python class function and ordinary function.
20.
Write the syntax for the following
(i) Creating objects
(ii) Accessing class members
21.
Write the general form of declaring class in Python.
22.
23.
How will you create constructor in Python?
24.
What is the output of the following program?
Class Sample:
__num=10
def disp(self):
print(self.__num)
S=Sample()
S.disp()
print(S.__num)
25.
What is class?
26.
Read the following program. Answer the following question. Class sample:
x, y= 10, 20
s= sample ()
print (s. x + s. y)
1. What does sample denotes?
2. What does x, y denotes?
3. What does s denotes?
27.
Fill up the blanks in the following program to get the output:
Value of x = 10
Value of y = 20
Sum of x and y= 30
Class sample:
x, __ = 10, 20 -------------------1
s = -------------------------2
print ("value of x =", __ ) ------------3
print ("value of y =", __ ) -------------4
print ("sum of x and y =", __ ) --------5
28.
Write a python program that illustrate the use of destructor.
29.
Why the following program give an error while displaying the value of n2. Give Reason.
30.
Explain the working of the following program. class Sample:
def _init_(self, num):
print("Constructor of class Sample ...")
self.num=num
print("The value is :", num)
S=Sample(10)
31.
Write a python program to find total and average marks using class.
32.
Write a note on object.
33.
What is the output of the following program?
class Greeting:
def __init__(self, name):
self.__name = name
def display(self):
print("Good Morning ", self.__name)
obj=Greeting ('Bindu Madhavan')
obj.display()
34.
Find the error in the following program to get the given output?
class Fruits:
def __init__(self, f1, f2):
self.f1 = f1
self.f2 = f2
def display(self):
print("Fruit 1 = %s, Fruit 2 = %s" %(self.f1, self.f2))
F = Fruits ('Apple', 'Mango')
del F.display
F.display()
Output: Fruit 1 = Apple, Fruit 2 = Mango
35.
What are class members? How do you define it?
36.
Write a program to store product and its cost price. Display all the available products and prompt to enter quantity of all the products. Finally generate a bill which displays the total amount to be paid.
37.
Write a program to accept a string and print the number of uppercase, lowercase, vowels, consonants and spaces in the given string.
38.
Write a menu driven program that keeps record of books available in you school library.
39.
Write a program to calculate area and circumference of a circle.
40.
Write a program to check and print if the given number is negative or positive using class.
41.
Write a python program to check and print if the given number is odd or even using class.
42.
Write a menu driven program to add or delete stationary items. You should use dictionary to store items and the brand.
1.
(a)
double underscore
2.
(b)
classname,.
3.
(c)
self
4.
(b)
Members
5.
(d)
Keyword
6.
(c)
Classes and objects
7.
(d)
None of these
8.
(a)
constructor
9.
(a)
First
10.
(c)
15
11.
(a)
Methods
12.
(b)
Tamil
13.
(c)
class class_name:
14.
(d)
__del__( )
15.
(c)
Classes and Objects
16.
(i) The variables which are defined inside the class is public by default. These variables can be accessed anywhere in the program using dot operator.
(ii) A variable prefixed with double underscore becomes private in nature. These variables can be accessed only within the class
17.
In the program, class variable num is shared by all three objects of the class Sample. It is initialized to zero and each time an object is created, the num is incremented by 1. Since, the variable shared by all objects, change made to num by one object is reflected in other objects as well
18.
Program to illustrate Constructor:
class Sample:
def _init_(self, num):
print("Constructor of class Sample...")
self.num=num
print("The value is :", num)
S = Sample(10)
Output:
constructor of class Sample..
The value is:10
19.
Python class function or method is very similar to ordinary function with a small difference. The class method must have the first argument named as self.
20.
(i) Object - name = class_name ()
(ll) Object - name = class_member
21.
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_n
22.
23.
(i) "Init" is a special function begin an end with double underscore in Python act as a Constructor .
(ii) Constructor function will automatically executed when an object is created.
General format of __init__ method
(Constructor function)
def __init__ (self, [args........])
<statements>
24.
Output:
>>>
10
line 7, in <module>
print(S._num)
AttributeError: 'Sample' object has no attribute '_num'
>>>
25.
(i) Class is the main building block in Python.
(ii) Class is a template for the object.
(iii) Object is a collection of data and function that act on those data.
(iv) Objects are also called as instances of a class.
26.
1. It denotes class name
2. x, y is a class variables of the class
3. S is an object created to access the members of the class
27.
1. - y
2. - sample 0
3. - s.x
4. - s. y
5. - s. x + s. y
28.
Program to illustrate about the _del_( ) method
class Sample:
num=()
def _init_(self, var):
Sample.num+= 1
self.var=var
print("The object value is = ", var)
print("The value of class variable is = ", Sample.num)
def _del_(self):
Sample.num-=1
print("Object with value %d is exit from the scope"%self.var)
S1=Sample(15)
S2=Sample(35)
S3=Sample(45)
29.
class Sample:
def _init_(self, n1, n2):
self.n1=n1
self._n2=n2
def display(self):
print("Class variable 1 = ", self.n1)
print("Class variable 2 = ", self._n2)
S=Sample(12,14)
S.display()
print("Value 1 = ", S.n1)
print("Value 2 = ". S._n2)
Reason: The print statements defined within class will successfully display the values of n1 and n2, even though the class variable n2 is private because, in this case, n2 is called by a method defined inside the class. But, when we try to access the value of n2 from outside the class Python throws an error because, private variable cannot be accessed from outside the class.
30.
(i) The above class "Sample': has only a constructor with one argument named as num. When the constructor gets executed, first the print statement, prints the "Constructor of class Sample ... " then, the passing value to the constructor is assigned to self.num and finally it prints the value passed along with the given string.
(ii) The above constructor gets executed automatically, when an object S is created with actual parameter 10. Thus, the Python displays the following output.
(iii) Constructor of class Sample ...
The value is: 10
Class variable defined within constructor keep count of number of objects created with the class.
31.
class Student:
mark1, mark2, mark3 = 45, 91, 71
#class variable
#class method
def process(self):
sum = Student.mark1 + Student.mark2 + Student.mark3
avg = sum/3
print("Total Marks = ", sum)
print("Average Marks = ", avg)
return
S=Student()
S.process()
Output:
Total marks = 207
Average Marks = 69.0
32.
(i) Object is a collection of data and function that act on those data. Class is a template for the object
(ii) According to the concept of Object Oriented Programming, objects are also called as instances of a class or class variable.
(iii) In Python, everything is an object. For example, all integer variables that we use in our program is an object of class into Similarly all string variables are also object of class string.
33.
Good Morning Bindu Madhavan.
34.
In line No.8, del F.display will not come.
35.
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.
Defining classes: In Python, a class is defined by using the keyword class. Every class has a unique name followed by a colon (:).
Syntax for Defining a Class:
class class_name:
statement_1
statement_2
....................
....................
statement_n
36.
class MyStore:
_prod_code= []
_prod_name= []
_ cost_price= []
_prod_quant= []
def getdata(self):
self.p = int(input("Enter no. of products you need to store: "))
for x in range(self.p):
self._prod_code.
append(int(input("Enter Product Code: ")))
self._prod_name.append(str(input("Enter Product Name: ")))
self._ cost_price.append(int(input("Enter Cost price: ")))
def display(self):
print("Stock in Stores")
print(" ---------------------------------- ")
print("Product Code \t Product Name \t Cost Price")
print(" ------------------------------------- ")
for x in range(self.p):
print(self._prod_code[x], "\t\t", self._prod_name[x], "\t\t", self._cos_ price [x])
print(" ---------------------------------")
def print_bill(self):
total_price = 0
for x in range( self.p):
q=int(input("Enter the quantify for the product code %d : "%self._ prod_code [x]))
self._prod_quant.append(q)
total_price = total_price +self._cost_
price[x]*self._prod_quant[x]
print(" Invoice Receipt ")
print(" --------------------------------------")
print("Product Code\t Product Name\t
Cost Price\t Quantity \t Total Amount")
print(" ------------------------------------ ")
for x in range(self.p):
print(self._prod_code[x], "\t\t", self._prod_name[x], "\t\t",
self._cost_price[x], "\t\t", self._prod_quant[x], "\t\t",
self._pro d_ quan t [x] *self._cost_price [x])
print(" -----------------------------------")
print(" Total Amount = ", total_price)
37.
Class String:
def _init_(self):
self.uppercase=()
self.lowercase=()
self.vowels=()
self.consonants=()
self.spaces=()
self.string= " "
def getstr (self):
self.string=str(input("Enter a String: "))
def count_upper(self):
for ch in self.string:
if (ch.isupper()):
self.uppercase+= 1
def count_Iowert(self):
for ch in self.string:
if (ch.islower()):
self.lowercase+= 1
def count_vowels(self):
for ch in self.string:
if (ch in ('A', 'a', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U')):
self.vowels+=1
def count_consonants(self):
for ch in self.string:
if (ch not in ('A', 'a', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U')):
self.consonants+= 1
def count_space(self):
for ch in self.string:
if (ch==" ''):
self.spaces+= 1
def execute(self):
self.count_upper()
self.count_lower ()
self.count_vowels ()
self.count_consonants()
self.count_space()
def display(self):
print("The given string contains ...")
print("%d Uppercase letters"%self. uppercase)
print("%d Lowercase letters"%self. lowercase)
print("%d Vowels"%self.vowels)
print("%d Consonants"%self.consonants)
print("%d Spaces"%self.spaces)
S = String()
S.getstr()
S.execute()
S.display()
Output:
Enter a string: Welcome To Learn Computer Science
The given string contains...
5 Uppercase letters
24 Lowercase letters
13 vowels
20 consonants
4 Spaces
38.
class Library:
def _init_(self):
self.bookname= ""
self.author='"
def getdata(self):
self.bookname = input("Enter Name of the Book: ")
self.author = input("Enter Author of the Book: ")
def display(self):
print("Name of the Book: ",self.bookname)
print("Author of the Book: ",self.author)
print("\n")
book= [] #empty list
ch = 'y'
while( ch=='y'):
print("1. Add New Book \n 2.Display Books")
resp = int(input("Enter your choice: "))
if(resp==1):
L=Library()
L.getdata()
book.append(L)
elif(resp==2):
for x in book:
x.display()
else:
print("Invalid input....")
ch = input("Do you want continue ....")
Output
1. Add New Book
2. Display Books
Enter your choice: 1
Enter Name of the Book: Programming in C++
Enter Author of the Book: K. Kannan
Do you want to continue...y
1. Add New Book
2. Display Books
Enter your choice: 1
Enter Name of the Book: Advanced Python
Enter Author of the Book: Dr. vidhya
Do you want continue.... n
39.
class Circle:
pi=3.14
def _init_(self.radius):
self.radius=radius
def area(self):
return Circle. pi*(self.radius**2)
def circumference(self):
return 2*Circle.pi*self.radius
r=int(input("Enter Radius: "))
Ce=Circle(r)
print("The Area =",C.area())
print("The Circumference =", Cxircumferencet())
40.
class test;
def check (self, num)
if num> 0:
print (num, "is positive number")
else:
print (num, "is negative number")
n = test ()
x = int (input("Enter the number"))
n. check (x)
41.
class Odd_Even:
even = 0 #class varaiable
def check(self, num):
if num%2==0:
print(num," is Even number")
else:
print(num," is Odd number")
n=Odd Even()
x = int(input("Enter a value:"))
n.check(x)
when we execute this program, Python accepts the value entered by the user and passes it to the method check through object.
Output:1
Enter a value: 4
4 is Even number
Output: 2
Enter a value: 5
5 is Odd number
42.
class Mystore:
_prod_code = [ ]
_prod_name = [ ]
_cost price = [ ]
_prod quant = [ ]
def getdata(self):
selt.p= int (input ("Enter no. of products you need to store:"))
for x in range (self.p):
self._prod_code. append (int (input ("Enter Product Code:")))
self._prod_name. append (str (input ("Enter Product Name:"))
self._ cost_price. append (int (input ("Enter cost price:"))
def display (self):
print ("stock in stores")
print ("---------------------")
print ("Product Code\t Product name\t cost price")
print ("------------------")
for x in range (self.p):
print (self._prod_code [x], "\t\t", self._prod_name [x], "It \t", self._cost price [x])
print ("------------------------------")
def print_bill (self):
total_price =0
for x in range (self.p):
q= int(input("Enter the quantity for the product code %d:" %self._prod_code [x]))
self. Prod_quant.append (q)
total_price = total_price + self. _cost_price|x]* self._prod_quant [x]
print ("Invoice Receipt")
print ("---------------")
print ("Product Code\t Product Name\t Cost Price\t Quantity\t Total Amount")
print ("----------------")
for x in range (self.p):
print (self._Prod_code [x), "\t \t", self_prod-name[x], "\t \t",
self._cost_price[x], "\t \t", self._prod-quant [x], "\t \t",
self._prod_quant[x]*self._cost price [x])
print ("-------------------")
print ("Total Amount =", total_price")
S=Mystore ()
S.getdata ()
S.display ()
S.print_bill ()
Output:
Enter no. of products you need to store: 5
Enter Product code: 101
Enter Product Name: Notebook
Enter cost price: 25
Enter Product code: 201
Enter Product Name: pencil
Enter cost price: 35
Enter Product code: 301
Enter Product Name: Pen
Enter cost price: 35
Enter Product code: 401
Enter Product Name: Colour Pencils
Enter cost price: 50
Enter Product code: 501
Enter Product Name: Sketches
Enter cost price: 120
Stock in stores
| Product Code | Product Name | Cost Price |
| 101 | Notebook | 25 |
| 201 | Pencil | 35 |
| 301 | Pen | 35 |
| 401 | Colour pencils | 50 |
| 501 | Sketches | 120 |
Enter the quantity for the product code 101:10
Enter the quantity for the product code 201:15
Enter the quantity for the product code 301:10
Enter the quantity for the product code 401:20
Enter the quantity for the product code 501:10
Invoice Receipt
| Product Code | Product Name | Cost Price | Quantity | Total Amount |
| 101 | Notebook | 25 | 10 | 250 |
| 201 | Pencil | 35 | 15 | 525 |
| 301 | Pen | 35 | 10 | 350 |
| 401 | Colour pencils | 50 | 20 | 1000 |
| 501 | Sketches | 120 | 10 | 1200 |
| Total amount = 3325 |
12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications களப்பெயர் முறைமை (DNS) Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு எடுத்துக்காட்டுகள் மற்றும் நெறிமுறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications கணினி வலையமைப்பு ஓர் அறிமுகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications PHP-உடன் MySQL-ஐ இணைத்தல் Sample Question Papers Study Material - QB365 Set A
Tamilnadu Stateboard 12th Standard Subjects

Maths

Chemistry

Physics

Biology

Computer Science

Business Maths and Statistics

Economics

Commerce

Accountancy

History

Computer Applications

Biology

Computer Technology

Computer Applications

Computer Science

Business Maths and Statistics

Commerce

Economics

Maths

Chemistry

Physics

Computer Technology

History

Accountancy

Tamil

English

French
Tamilnadu Stateboard Standards