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: 02/02/2021
12th Standard Computer Science English Medium Reduced Syllabus Important Questions - 2021 Part - 1
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.
Which of the following is a simple abstraction of complex real world data gathering environment?
Data redundancy
Data consistency
Data abstraction
Data model
2.
In the command python <filename.py> -
Information
Input mode
ios
Interpreter
3.
In Python, for loop uses the ____ function in the sequence to specify the initial final and increment values.
Input ()
print ()
range ()
sequence ()
4.
__________ represents an abstraction of the sequence of numbers
Dictionary
List
Set
Tuple
5.
_______are languages that uses meaningful statements about time and space complexity?
Time and space trade
Asymptotic notations
Complexity notations
Algorithmic notations
6.
Using sort (), the default sorting is
ascending
descending
no sorting
criteria sorting
7.
Which of the following could be designed to get a solution of a given problem?
Program
Algorithm
Flowchart
Input/Output
8.
The output function ______ is used to display the result of the Python Program.
out ()
write ()
print ()
execute ()
9.
A Function always first look up for a variable name in its______ scope
Local
Enclosed
Global
Built-in
10.
From the following statement absence of which one no message is displayed on the screen? variable = input ("prompt string")
Variable
input
"prompt string"
" "
11.
The basic idea of ________ is to structure programs so that they operate on abstract dat(a)
Encapsulation
Polymorphism
Data type
Data Abstraction
12.
The____________ can be implemented using singly linked list or doubly linked list
Tuple ADT
List ADT
Function ADT
List ADT
13.
In which data representation, a definition for each function is known
User defined
Buil-in
Abstract
Concrete
14.
Which of the following are expressed using statements of a programming language?
Functions
Algorithm
Interface
Implementation
15.
Identify the function call statement in the following snippet.
if __name__ =='__main__':
main(sys.argv[1:])
main(sys.argv[1:])
__name__
__main__
argv
16.
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
17.
Which of the following is used as placeholders or replacement fields which get replaced along with format( ) function?
{ }
< >
++
^^
18.
Which function is called anonymous un-named function?
Lambda
Recursion
Function
define
19.
Which of the following functions that retrieve information from the data type?
Constructors
Selectors
recursive
Nested
20.
Which of the following is a unit of code that is often defined within a greater code structure?
Subroutines
Function
Files
Modules
21.
Write a note on main (sys.argv [1]).
22.
Write a program in python to check if the accepted number even or odd.
a = int(input("Enter any number:"))
if a%2==0:
print (a, "is an even number")
else:
print (a, "is an odd number")
23.
What are the three asymptotic notations used to represent time complexity of algorithms?
24.
Give an example. How the time efficiency of an algorithm is measured.
25.
Write the syntax of input () used in python.
26.
What is modular programming?
27.
How a class defines a data abstraction?
28.
Construct on algorithm that arranges meetings between these two types so that they change their color to the third type. In the end, all should display the same color.
29.
What is the theoretical difference between Scripting language and other programming language?
30.
How will you delete a string in Python?
31.
Do you modify a string in Python?
32.
What is String?
33.
34.
What is an Algorithm?
35.
Define Function with respect to Programming language.
36.
How will you generate queries and retrieve data from the table? Explain?
37.
List the data types used in SQL.
38.
How the data in RDBMs is stored? Explain.
39.
Explain how a connect to be made to a database (Academy through python SQlite3.
40.
Write an algorithm for executing C++ program pali_cpp.cpp using python program.pall.py.
41.
Write a pseudo code that defines Fibonacci Iterative algorithm with Dynamic programming approach.
42.
What is dynamic programming? What are the steps involved in dynamic programming?
43.
Write the different factors in which the time efficiency of an algorithm its measured
44.
Design an algorithm to find square of the given number and display the result.
45.
Fill up the blanks to get the following output from Python code given.
Output:
Enter Number 1: 34
Enter Number 2: 70
The Sum = 104
Code:
X = \(\overset { (1) }{ \_ \_ \_ \_ \_ } \) (input ("Enter Number 1:"))
Y = \(\overset { (2) }{ \_ \_ \_ \_ \_ } \) (\(\overset { (3) }{ \_ \_ \_ \_ \_ } \) ("Enter Number 2 :"))
\(\overset { (4) }{ \_ \_ \_ \_ \_ } \) ("The sum =", \(\overset { (5) }{ \_ \_ \_ \_ \_ } \))
46.
Write a note on Data Abstraction.
47.
Write an algorithm to check whether the entered number is even or odd.
48.
What do you understand by Dynamic programming?
49.
Discuss about Algorithmic complexity and its types.
50.
Differentiate Concrete data type and abstract datatype.
51.
Explain ALTER command in detail.
52.
Explain the components of DBMS.
53.
Write a python program to execute the following C++ program
To implement Multilevel Inheritance:
// C++ program to implement Multilevel Inheritance
// Now select File ⟶New in Notepad and type the C++ program
c++ Program.
#include < iostream >
using namespace std;
// base class
class Vehicle
{
public:
Vehicle ( )
{
cout<< "This is a Vehicle" << endl;
}
};
class threeWheeler: public Vehicle
{ public:
three Wheeler ( )
{
cout << "Objects with 3 wheels are vehicles" << endl;
}
};
// sub class derived from two base classes
class Auto: public threeWheeler{
public:
Auto ( )
{
cout<< "Auto has 3 Wheels"<< endl;
};
// main function
int main ( )
{
//creating object of sub class will invoke the constructor of base classes
Auto obj;
return 0;
}
// Save this file as inheri_cpp.cpp
54.
Write a program to set data at runtime and writing it in a CSV file.
55.
Explain with an example how will you return multiple values in tuples.
56.
How will access all elements of a list? Write the execution table example.
57.
Write a Python script to create a table called ITEM with following specification.
Add one record to the table.
Name of the database :- ABC
Name of the table :- Item
Column name and specification :-
| I code | :- | Integer and act as primary key |
| Item Name | :- | Character with length 25 |
| Rate | :- | Integer |
| Record to be added | :- | 1008, Monitor, 15000 |
58.
Write the rules to be followed to format the data in a CSV file.
59.
Explain the concept of Dynamic programming with suitable example.
60.
Explain input() and print() functions with examples.
61.
Describe in detail the procedure Script mode programming.
62.
Write any five benefits in using modular programming.
63.
Explain the types of scopes for variable or LEGB rule with example.
64.
How will you facilitate data abstraction. Explain it with suitable example.
1.
(d)
Data model
2.
(b)
Input mode
3.
(c)
range ()
4.
(d)
Tuple
5.
(b)
Asymptotic notations
6.
(a)
ascending
7.
(b)
Algorithm
8.
(c)
print ()
9.
(a)
Local
10.
(c)
"prompt string"
11.
(d)
Data Abstraction
12.
(b)
List ADT
13.
(d)
Concrete
14.
(b)
Algorithm
15.
(a)
main(sys.argv[1:])
16.
(c)
Classes and Objects
17.
(a)
{ }
18.
(a)
Lambda
19.
(b)
Selectors
20.
(b)
Function
21.
maintsv (sys.argv[1]) Accepts the program file (Python program) and the input file (C++file) as a list(array). argv[0] contains the Python program which is need not to be passed because by default _main_ contains source code reference and argv (1) contains the name of the C++ file which is to be processed.
22.
Output:
Enter any number: 56
56 is an even number
Output 2:
Enter any number: 67
67 is an odd number
23.
(i) BigO
(ii) BigW
(Iii) Big \(\mu \)
24.
The time efficiency of an algorithm is measured by different factors. For example, write a program for a defined algorithm, execute it by using any programming language, and measure the total time it takes to run.
25.
Variable = input ("prompt string")
Where, prompt string in the syntax is a statement or message to the user, to know what input can be given.
26.
The process of subdividing a computer program into separate sub-programs is called modular programming.
27.
(i) A class defines a data abstraction by grouping related data items. A class is not just data, it has functions defined within it.
(ii) Functions are subordinate to the class because their job is to do things with the data of the class.
28.
let rec monochromatize a b c :=
if a > 0 then
a, b, c:= a-1, b-1, c+2
else
a:=0, b:=0, c:= a + b + c
return c
29.
(i) The theoretical difference between the two is that scripting languages do not require the compilation step and are rather interpreted.
(ii) For example, normally, a C++ program needs to be compiled before running whereas, a scripting language like JavaScript or Python need not be compiled.
(iii) A scripting language requires an interpreter while a programming language requires a compiler.
30.
Python will not allow deleting a particular character in a string. Whereas you can remove entire string variable using del command.
Example :
>>> strl="How about you"
>>> print (str1)
How about you
>>> del str1
>>> print (str1)
Traceback (most recent call last):
File "
print (strl)
NameError : name 'str1' is not defined
31.
Strings in python are immutable. That means, once you define a string moditications or deletion is not allowed. However, we can replace the existing string entirely with the new string.
32.
(i) String is a data type in python, which is used to handle array of characters.
(ii) String is a sequence of Unicode characters that may be a combination of letters, numbers, or special symbols enclosed within single, double or even triple quotes.
(iii) Example :
Welcome to learning Python"
"Welcome to learning Python"
""Welcome to learning Python""
33.
34.
An algorithm is a finite set of instructions to accomplish a particular task. It is a step-by-step procedure for solving a given problem.
35.
A function is a unit of code that is often defined within a greater code structure. Specifically, a function contains a set of code that works on many kinds of inputs, like variables, expressions and produces a concrete output.
36.
One of the most important tasks when working with SQL is to generate Queries and retrieve data. A Query is a command given to get a desired result from the database table. The SELECT command is used to query or retrieve data from a table in the database. It is used to retrieve a subset of records from one or more tables. The SELECT command can be used in various forms:
Syntax of SELECT command:
SELECT < column-list > FROM < table-name > ;
(i) Table-name is the name of the table from which the information is retrieved.
(ii) Column-list includes one or more columns from which data is retrieved.
37.
(i) char (Character)
(ii) varchar
(iii) dec (Decimal)
(iv) numeric
(v) int (Integer)
(vi) smallint
(vii) float
(viii) real
(ix) double
38.
(i) The data in RDBMS, is stored in database objects, called Tables. A table is a collection of related data entries and it consist of rows and columns.
(ii) A field is a column in a table that is designed to maintain specific related information about every record in the table. It is a vertical entity that contains all information associated with a specific field in a table. The fields in a student table may be of the type AdmnNo, StudName, StudAge, StudClass, Place etc
(iii) A Record is a row, which is a collection of related fields or columns that exist in a table. A record is a horizontal entity in a table which represents the details of a particular student in a student table
39.
# Python code to demonstrate table creation and insertions with SQL
# importing module
import sqlite3
# connecting to the database
connection = sqlite3.connect ("Academy.db")
# cursor
cursor = connection.cursor ( )
40.
Step 1: Type the C++ program to check whether the input number is palindrome or not in notepad and save it as "pali_cpp.cpp".
Step 2: Type the Python program and save it as pali.py.
Step 3: Click the Run Terminal and open the command window
Step 4: Go to the folder of Python using cd command
Step 5: Type the command Python pali.py -i pali_cpp
41.
The following shows a simple Dynamic programming approach for the generation of Fibonacci series.
Initialize f0 = 0,f1 =1
Step 1 - Print the initial values of Fibonacci f0 and f1
Step 2 - Calculate fibanocci fib \(\leftarrow \) f0+ f1
Step 3 - Assign f0\(\leftarrow \) fl , f1\(\leftarrow \) fib
Step 4 - Print the next consecutive value of fibanocci fib
step 5 - Goto step-2 and repeat until the specified number of terms generated
For example if we generate fibobnacci series upto 10 digits, the algorithm will generate the series as shown below:
The Fibonacci series is : 0 1 1 2 3 5 8 13 21 34 55
42.
Dynamic programming is an algorithmic design method that can be used when the solution to a problem can be viewed as the result of a sequence of decisions. Dynamic Programming approach is similar to divide and conquer.
(i) The given problem will be divided into smaller overlapping sub-problems.
(ii) An optimum solution for the given problem can be achieved by using result of smaller sub-problem.
(iii) Dynamic algorithms uses Memoization.
43.
The execution time that you measure in this case would depend on a number of factors such as:
(i) Speed of the machine
(ii) Compiler and other system Software tools
(iii) Operating System
(iv) Programming language used
(v) Volume of data required
44.
The algorithm can be written as:
Step 1: start the process
Step 2: get the input x
Step 3: calculate the square by multiplying the input value ie., square \(\leftarrow \)x* x
Step 4: display the result square
Step 5: stop
45.
(1) int
(2) int
(3) input
(4) print
(5) x + y
46.
(i) Data abstraction is supported by defining an abstract data type (ADT) which is a collection of constructors and selectors.
(ii) Constructors create an object, bundling together different pieces of information, while selectors extract individual pieces of information from the object.
47.
(requires: x>= 0)
let rec even x :=
x=0II odd (x-I)
return 'even'
(requires: x > = 0)
let odd x :=
x< >0 && even (x-I)
return 'odd'
48.
(i) Dynamic programming is an algorithmic design method that can be used when the solution to a problem can be viewed as the result of a sequence of decisions.
(ii) Dynamic programming approach is similar to divide and conquer. The given problem is divided into smaller and yet smaller possible sub-problems.
(iii) Dynamic programming is used whenever problems can be divided into similar sub-problems. So that their results can be re-used to complete the process.
(iv) Dynamic programming approaches are used to find the solution in optimized way. For every inner subproblem, dynamic algorithm will try to check the results of the previously solved sub-problems. The solutions of overlapped sub-problems are combined in order to get the better solution.
49.
The complexity of an algorithm f (n) gives the running time and/or the storage space required by the algorithm in terms of n as the size of input data.
(i) Time Complexity: The Time complexity of an algorithm is given by the number of steps taken by the algorithm to complete the process.
(ii) Space Complexity: Space complexity of an algorithm is the amount of memory required to run to its completion.
50.
| S.No | Concrete data type | Abstract data type |
| (i) | Concrete Data Types or structures (CDT's) are direct implementations of a relatively simple concept | Abstract Data Types (ADT's) offer a high level view (and use) of a concept independent of its implementation. |
| (ii) | A concrete data type is a data type whose representation is known. | Abstract data type the representation of a data type is unknown. |
51.
ALTER Command:
(i) The ALTER command is used to alter the table structure like adding a column, renaming the existing column, change the data type of any column or size of the column or delete the column from the table. It is used in the following way:
(ii) ALTER TABLE <table-name>
(iii) To add a new column "Address" of type 'char' to the Student table, the command is used as
(iv) ALTER TABLE Student ADD Address char;
To modify, existing column of table, the ALTER TABLE command can be used with MODIFY clause like wise:
(v) ALTER < table-name > MODIFY < column-name > < data type > < size >;
ALTER TABLE Student MODIFY Address char (25);
(vi) The above command will modify the address column of the Student table to now hold 25 characters.
(vii) The ALTER command can be used to rename an existing column in the following way:
(viii) ALTER < table-name > RENAME old-column- name TO new-column-name;
(ix) For example to rename the column Address to City, the command is used as :
(x) ALTER TABLE Student RENAME Address TO City;
(xi) The ALTER command can also be used to remove a column or all columns. for example to remove a particular column, the DROP COLUMN is used with the ALTER TABLE to remove a particular field, the command can be used as:
ALTER < table-name > DROP COLUMN < column-name >;
(xii) To remove the column City from the Student table, the command is used as :
ALTER TABLE Student DROP COLUMN City;
52.
The Database Management System can be divided into five major components as follows:
(i) Hardware
(ii) Software
(iii) Data
(iv) Procedures / Methods
(v) Database Access Languages
(i) Hardware: The computer, hard disk, I/O channels for data, and any other physical component involved in storage of data
(ii) Software: This main component is a program that controls everything. The DBMS software is capable of understanding the Database Access Languages and interprets into database commands for execution.
(iii) Data: It is that resource for which DBMS is designed. DBMS creation is to store and utilize data.
(iv) Procedures/Methods: They are general instructions to use a database management system such as installation of DBMS, manage databases to take backups, report generation, etc
(v) DataBase Access Languages: They are the languages used to write commands to access, insert, update and delete data stored in any database.
Examples of popular DBMS: Dbase, FoxPro
53.
//Now select File ➝ New in Notepad and type the Python program
# Save the File as classpy.py
# Python classpy.py -i inheri_cpp command to execute c++ program
Python Program:
import sys, os, getopt
def main (argv):
cpp_file ="
exe_file ="
opts.args= getopt.getopt (argv, "i:",['ifile='])
for o, a in opts:
1ifile. ("'-"1", --ifile"):
cpp_file = a + '.cpp'
exe_file = a + '.exe'
run (cppfile, exe_file)
def run(cpp_file, exe_file):
print ("Compiling" + cpp_file)
os.system ('g++ ' + cpp_file + '-o' + exe_file)
print ("Running" + exe_file)
print ("------------------- ")
print
os.system (exe_file)
print
if __name__ =='__main__"
main (sys.argv[1:])
54.
import csv
with open ('c\\pyprg\\ch13\\ dynamicfile.csv', 'w') as f:
w = csv.writer(f)
ans= 'y'
while (ans=='y'):
name=input("Name?:")
date=input("Date of birth:")
Place=input ("Place:")
w.writerow([name, date, place])
ans=input("Do you want to enter more y/n?:")
F=open('c:\\pyprg\\ch13\\dynamicfile.csv",r')
reader=csv.reader(F)
for row in reader:
print (row)
F.close()
55.
(i) A function can return only one value at a time, but Python returns more than one value from a function. Python groups multiple values and returns them together.
(ii) Example: Program to return the maximum as well as minimum values in a list
def Min_Max(n):
a = max(n)
b = min(n)
return (a, b)
Num = (12, 65, 84, 1, 18, 85, 99)
(Max_Num, Min_Num) = Min_Max(Num)
print("Maximum value = ", Max_Num)
print("Minimum value = ", Min_Num)
(iii) Output:
Maximum value = 99
Minimum value = 1
56.
(i) Loops are used to access all elements from a list. The initial value of the loop must be zero. Zero is the beginning index value of a list.
(ii) Example:
Marks = [10, 23, 41, 75]
i = 0
while i < 4:
print (Marks[i])
i = i + 1
Output:
10
23
41
75
(iii) In the above example, Marks list contains four integer elements i.e., 10, 23, 41, 75. Each element has an index value from 0. The index value of the elements are 0, 1, 2, 3 respectively.
(iv) Here, the while loop is used to read all the elements. The initial value of the loop is zero, and the test condition is < 4, as long as the test condition is true, the loop executes and prints the corresponding output
(iv) During the first iteration, the value of i is zero, where the condition is true. Now, the following statement print (Marks [i] gets executed and prints the value of Marks [0] element ie. 10.
(v) The next statement i = i + 1 increments the value of i from 0 to 1. Now, the flow of control shifts to the while statement for
(vi) checking the test condition. The process repeats to print the remaining elements of Marks list until the test condition of while loop becomes false. The following table shows that the execution of loop and the value to be print.
| Iteration | i | while i < 4 |
print (Marks[i]) | i = i + 1 |
| 1 | 0 | 0< 4 True | Marks [0] =10 | 0+1=1 |
| 2 | 1 | 1 < 4 True | Marks [1]=23 | 1+1=2 |
| 3 | 2 | 2 < 4 True | Marks [2]=41 | 2+1=3 |
| 4 | 3 | 3 < 4 True | Marks [3]=75 | 3+1=4 |
| 5 | 4 | 4 < 4 False |
57.
Program:
import mysql db
db = mysqldb.connect ("local host", "user", "123", "organization'")
cursor = db.cursor()
item table creation
database: ABC, table: Item, lcode: int, ItemName: Char
Rate: int. Record: 1008, Monitor: 15000
cursor.execute ("Create table item(icode int, item Name char (25), Rate int"));
db.close
cursor. execute ("insert into item values ("1008", 'Monitor', '15000" ));
db.commit()
58.
Rules to be followed to format data in a CSV file:
(i) Each record (row of data) is to be located on a separate line, delimited by a line break by pressing enter key.
For example:↲
xxx,yyy↲
↲denotes enter Key to be pressed
(ii) The last record in the file mayor may not have an ending line break.
For example:
ppp, qqq↲
yyy, xxx
(iii) There may be an optional header line appearing as the first line of the file with the same format as normal record lines. The header will contain names corresponding to the fields in the file and should contain the same number of fields as the records in the rest of the file.
For example:
field_name 1, field_name 2, field_name 3↲
aaa,bbb,ccc↲
zzz, yyy, xxx CRLF(Carriage Return and Line Feed)
(iv) Within the header and each record, there may be one or more fields, separated by commas. Spaces are considered part of a field and should not be ignored. The last field in the record must not be followed by a comma.
For example:
Red, Blue
(v) Each field mayor may not be enclosed in double quotes. If fields are not enclosed with double quotes, then double quotes may not appear inside the fields
For example:
"Red","Blue","Green"↲
Black, White, Yellow
(vi) Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes.
For example:
Red, ",", Blue CRLF
Red, Blue, Green
(vii) If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be preceded with another double quote.
For example:
"Red, " "Blue", "Green",
White
59.
(i) Dynamic programming is an algorithmic design method that can be used when the solution to a problem can be viewed as the result of a sequence of decisions.
(ii) Dynamic programming approach is similar to divide and conquer. The given problem is divided into smaller and yet smaller possible sub-problems.
(iii) Dynamic programming is used whenever problems can be divided into similar subproblems. so that their results can be reused to complete the process.
(iv) Dynamic programming approaches are used to find the solution in optimized way. For every inner subproblem, dynamic algorithm will try to check the results of the previously solved sub-problems.
(v) The solutions of overlapped sub-problems are combined in order to get a better solution.
Steps to doDynamic programming :
(i) The given problem will be divided into smaller overlapping sub-problems.
(ii) An optimum solution for the given problem can be achieved by using result of smaller sub-problem.
(iii) Dynamic algorithms uses Memoization
Fibonacci Series - An example :
(i) Fibonacci series generates the subsequent number by adding two previous numbers. Fibonacci series starts from two numbers -Fib 0 & Fib 1. The initial values of Fib 0 & Fib l can be taken as 0 and 1.
(ii) Fibonacci series satisfies the following conditions:
Fibn = Fiba-1 + Fiba-2
(iii) Hence, a Fibonacci series for the n value 8 can look like this
Fib8 = 0 1 1 2 3 5 8 13
Fibonaeci Iterative Algorithm with Dynamic programning approach : The following example shows a simple Dynamic programning approach for the generation ot Fibonacci series.
Initialize f0 = 0, f1 = 1.
Step- 1: Print the initial values of Fibonacci f0 and f1
Step- 2: Calculate Fibonacci fib \(\leftarrow \) f0+ f1
Step- 3: Assign f0 \(\leftarrow \) f1, f1 \(\leftarrow \) fib
Step- 4: Print the next consecutive value of Fibonacci fib
Step- 5: Go to step-2 and repeat until the specified number of terms generated
Example:
if we generate Fibonacci series up to 10 digits, the algorithm will generate the series as shown below:
The Fibonacci series is:
0 1 1 2 3 5 8 13 21 34 55.
60.
1. The print () Function:
ln Python, the print() function is used to display result on the screen. The syntax for print ( ) is as follows:
Example:
print ("String to be displayed as output")
print (variable)
print ("String to be displayed as output", variable)
print ("String1", variable, "string 2", variable, "String 3",....)
Example:
>>> print("Welcome to python Programming'")
welcome to Python Programoming
>>>x = 5
>>> y = 6
>>> z= X+Y
>>> print (z)
>>> print ("The sum =", z)
The sum = 11
>>>print ("The sum of", x, "and", y, "is", z)
The sum of 5 and 6 is 11.
The print () evaluates the expression before printing it on the monitor. The print () displays an entire statement which is specified within print(). Comma(,) is used as a separator in print () to print more than one item.
input () function:
In Python, input) function is used to accept data as input at run time. The syntax for input () function is
Syntax:
Variable = input ("prompt String')
Where, prompt string in the Syntax is a statement or message to the user, to knowwhat input can be given.
If a prompt string is used, it is displayed on the monitor; the user can provide expected data from the input device. The input() takes whatever is typed from the Keyboard and stores the entered data in the given Variable. If prompt string is not given in input() no message is displayed on the screen, then, the user will not know what is to be typed as input.
Example 1:
input () with prompt String
>>>City=input ("Enter your city:")
Enter your city: Madurai
>>>print ("I am from", city)
I am from Madurai
Example 2:
input() without prompt string
>>> city = input ()
Rajarajan
>>>print ("I am from", city)
I am from Rajarajan
in Example 2, the input () is not having any pronmpt string, thus the user will not know what is to be typed as input. If the user inputs irrelevant data as given in the above example then the output will be unexpected. So, to make your program more interactive, provide prompt string with input (). The input () accepts all data as string or characters but not as numbers. Ifa numerical value is entered, the input values should be explicitly converted into numeric data type. The int) function is used to convert string data as integer data explicitly.
Example 3:
X=int (input ("Enter Number 1:"))
Y= int (input ("Enter Number 2:" ))
print ("The Sum =", x + y)
Output:
Enter Number 1: 34
Enter Number 2:56
The Sum =90.
61.
A script is a text file containing the Python statements. Python Scripts are reusable code. Once the script is created, it can be executed6again and again without retyping. The Scripts are editable
i) Creating Scripts in Python:
1. Choose File → New File or press Ctrl + N in Python shell window.
2. An untitled blank script text editor will be displayed on screen
3. Type the following code in script editor.
a = 100
b= 350
C = a + b
print ("The sum=", c)
ii) Saving Python script:
1. Choose File → Save or press Ctrl+S.
2. Now, Save As dialog box appears on the screen.
3. In the Sare As dialog box, select the location where you want to save your Python code, and type the File name in File Name box. Python files are by default saved will extension • py. Thus, while creating Python Scripts using Pyrhons script editor, no need to specify the file extension.
4. Hinallyiclick save button to save your python script.
iii) Exccuthon Python Script:
1. Choose Run → Run module or Press F5.
2. If your code has any error, it will be shown in red color in the IDLE window, and Python describes the type of error occurred. To correct the errors, go back to Script editor, make corrections, save the file using Ctrl +s or File → Save and execute il again.
3, For all error line code, the output will appear in the IDLL window of Python.
62.
(i) Less code to be written.
(ii) A single procedure can be developed for reuse, eliminating the need to retype the code many times.
(iii) Programs can be designed more easily because a small teana deals with only a
small part of the entire code.
(iv) Modular programming allowS many programmers to collaborate on the same
application.
(v) The code is stored across multiple files.
(vi) Code is short, sirnple and easy to understand.
(vii) Errors can easily be identified, as they are localized to a subroutine or function.
(viii) The same code can be used in man applications.
(ix) The scoping of variables can easily be controlled.
63.
Types of Variable Scope:
There are 4 types of Variable Scope, let's discuss them one by one:
Local Scope:
(i) Local scope refers to variables defined in current function. Always, a function will first look up for a variable name in its local scope. Only if it does not find it there, the outer scopes are checked.
Look at this example
| 1. Disp(): 2. a:=7 3. print a 4. Disp() |
Entire program |
Output of the Program 7 |
(ii) On execution of the above code the variable a displays the value 7, because it is defined and available in the local scope.
Global Scope:
(i) A variable which is declared outside of all the functions in a program is known as global variable.
(ii) This means, global variable can be accessed inside or outside of all the functions in a program.
Example:
| 1. a:=10 2. Disp(): 3. a:=7 4. print a 5. Disp() 6. print a |
Entire program |
Output of the Program 7 10 |
(iii) On execution of the above code the variable 'a' which is defined inside the function displays the value 7 for the function call Disp() and then it displays 10; because a is defined in global scope.
Enclosed Scope:
(i) All programming languages permit functions to be nested. A function (method) with in another function is called nested function.
(ii) A variable which is declared inside a function which contains another function definition with in it, the inner function can also access the variable of the outer function. This scope is called enclosed scope.
(iii) When a compiler or interpreter search for a variable in a program, it first search Local, and then search Enclosing scopes. Consider
the following example:
| 1. Disp(): 2. a:=10 3. Disp1() 4. print a 5. Disp1() 6. print a 7. Disp() |
Entire Program |
Output of the Program 10 10 |
(iv) In the above example Disp1( ) is defined with in Disp( ). The variable 'a' defined in Disp( ) can be even used by Disp1( ) because it is also a member of Disp( ).
Built-in Scope:
(i) The built-in scope has all the names that are pre-loaded into the program scope when we start the compiler or interpreter.
(ii) Any variable or function which is defined in the modules of a programming language has Built-in or module scope. They are loaded as soon as the library files are imported to the program.Consider the following example.
| Library files associated with the software |
LEGB rule :
The LEGB rule is used to decide the order in which the scopes are to be searched
for scope resolution. The scopes are listed below in terms of hierarchy (highest to
lowest).
.png)
64.
Data abstraction is used to define an Abstract Data Type (ADT), which is a collection of constructors and selectors. T facilitate data abstraction,you will need to create two types of functions : Constructors and Selectors.
Constructors :
(i) Constructors are functions that build the abstract data type.
(ii) Constructors create an object, bundling together different pieces of information.
(iii) For example, say you have an abstract data type called city.
(iv) This city object will hold the city's name, and its latitude and longitude.
(v) To create a city object, you'd use a function like city = makecity (name, lat, lon).
(vi) Here makecity (name, lat, lon) is the constructor which creates the object city.

Selectors :
(i) Selectors are functions that retrieve information from the data type.
(ii) Selectors extract individual pieces of information fromn the object.
(iii) To extract the information of a city object, you wouldused functions like
getname(city)
getlat(city)
getlon(city)
These are the selectors because these functions extract the information of the city object.
.png)
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