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: 27/09/2019
Python Classes and Objects
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.
Write a note on public and private data members of python class.
2.
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)
3.
Write a program in python that illustrate the use of constructor.
4.
Write the syntax for the following
(i) Creating objects
(ii) Accessing class members
5.
Write the general form of declaring class in Python.
6.
7.
How will you create constructor in Python?
8.
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)
9.
What is instantiation?
10.
What is class?
1.
(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
2.
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
3.
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
4.
(i) Object - name = class_name ()
(ll) Object - name = class_member
5.
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
6.
7.
(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>
8.
Output:
>>>
10
line 7, in <module>
print(S._num)
AttributeError: 'Sample' object has no attribute '_num'
>>>
9.
Once a class is created, next to create an object or instance of that class. This process of creating object is called as "Class Instantiation".
10.
(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.
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