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: 10/09/2022
QB365 provides a detailed and simple solution for every Possible Creative Questions in Class 12 Computer Science Subject - Python Classes and Objects , English Medium. It will help Students to get more practice questions, Students can Practice these question papers in addition to score best marks.
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 Program to illustrate private and public variables.
2.
Write a program to illustrate class variable to keep count of objects created.
3.
Write a program to define a class and syntax for class instantiation
class Sample:
#class variables
x, y = 10, 20
S = Sample() #class instantiation
print ("value of_x=", S.x)
print ("value of_y=", S.y)
print ("value of x and y =", S.x + S.y)
4.
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?
5.
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
6.
Write a python program that illustrate the use of destructor.
7.
Why the following program give an error while displaying the value of n2. Give Reason.
8.
Write the output 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)
9.
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)
10.
Write a python program to find total and average marks using class.
11.
Write a note on self argument used in python class function.
12.
Write a note on object.
1.
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)
Output
class variable 1 = 12
class variable 2 = 14
value 1 = 12
Traceback (most recent call last):
File "D:/Python/class-Test-04.py", line 12, in <module>
print(value.2 =", S._n2)
Attribute Error: 'Sample' object has no attribute '_n2'
2.
class sample:
num = 0
def_init_(self, var):
Sample. num +=1
self.var = var
print ("The value is =", var)
print(" The count of objects created = ", Sample.num)
S1 = Sample (15)
S2 = Sample (35)
S3 = Sample (45)
Output:
The object value is = 15
The count of object created = 1
The object value is = 35.
The count of object created = 2
The object value is = 45.
The count of object created = 3
3.
Output:
value of x = 10
value of Y = 16
value o f x and y = 30
4.
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
5.
1. - y
2. - sample 0
3. - s.x
4. - s. y
5. - s. x + s. y
6.
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)
7.
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.
8.
Output:
The object value is = 15
The count of object created = 1
The object value is = 35
The count of object created = 2
The object value is = 45
The count of object created = 3
9.
(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.
10.
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
11.
(i) Python class function or Method is very similar to ordinary function with a small difference that, the class method must have the first argument named as self.
(ii) No need to pass a value for this argument when we call the method. Python provides its value automatically.
(iii) Even if a method takes no arguments, it should be defined with the first argument called self.
(iv) If a method is defined to accept only one argument it will take it as two arguments ie. self and the defined argument.
12.
(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.
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