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: 19/10/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.
Functions of the class are called as
Methods
Members
Variables
Loog
2.
Which of the following is not an object oriented language?
C
C++
Java
Python
3.
The process of creating an object is called as:
Constructor
Destructor
Initialize
Instantiation
4.
Which of the following class declaration is correct?
class class_name
class class_name<>
class class_name:
class class_name[ ]
5.
Which of the following method is automatically executed when an object is created?
__object__( )
__del__( )
__func__( )
__init__( )
6.
Functions defined inside a class:
Functions
Module
Methods
section
7.
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?
11.
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()
12.
Write a class with two private class variables and print the sum using a method.
13.
What are class members? How do you define it?
14.
Write a program to accept a string and print the number of uppercase, lowercase, vowels, consonants and spaces in the given string.
15.
Write a program to calculate area and circumference of a circle.
16.
Write a menu driven program to add or delete stationary items. You should use dictionary to store items and the brand.
17.
Ghoose the correct statement from the following
(a) objectname = classname
(b) objectname: classname ()
(c) objectname = classname ()
(d) objectname:: classname ()
18.
Which of the following is correct declaration of constructor?
(a) - - init - -
(b) - - init- - ()
(c) - - classname - - ()
(d) - - classname - - ()
1.
(a)
Methods
2.
(a)
C
3.
(d)
Instantiation
4.
(c)
class class_name:
5.
(d)
__init__( )
6.
(c)
Methods
7.
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.
11.
Good Morning Bindu Madhavan.
12.
Code:
class Sample:
def_init_(self, n1, n2):
self._n1=nt
self_n2-n2
def sum(self):
print ("Class Variable 1:" self_n1)
print ("Class Variable 2:", self_n2)
S=Sample (5,10)
S.sum()
Output:
Class Variable 1:5
Class Variable 2: 10
Sum: 15
13.
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
14.
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
15.
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())
16.
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 |
17.
(c) objectname = classname ()
18.
(b) - - init- - ()
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