Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Tamilnadu State Board New Syllabus Samacheer Kalvi 12th Computer Science Guide Pdf Chapter 12 Structured Query Language (SQL) Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 12th Computer Science Solutions Chapter 12 Structured Query Language (SQL)

12th Computer Science Guide Structured Query Language (SQL) Text Book Questions and Answers

I. Choose the best answer (I Marks)

Question 1.
Which commands provide definitions for creating table structure, deleting relations, and modifying relation schemas.
a) DDL
b) DML
c) DCL
d) DQL
Answer:
a) DDL

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 2.
Which command lets to change the structure of the table?
a) SELECT
b) ORDER BY
c) MODIFY
d) ALTER
Answer:
d) ALTER

Question 3.
The command to delete a table is
a) DROP
b) DELETE
c) DELETE ALL
d) ALTER TABLE
Answer:
a) DROP

Question 4.
Queries can be generated using
a) SELECT
b) ORDER BY
c) MODIFY
d) ALTER
Answer:
a) SELECT

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 5.
The clause used to sort data in a database
a) SORT BY
b) ORDER BY
c) GROUP BY
d) SELECT
Answer:
b) ORDER BY

II. Answer the following questions (2 Marks)

Question 1.
Write a query that selects all students whose age is less than 18 in order wise.
Answer:
SELECT * FROM STUDENT WHERE AGE <= 18 ORDER BY NAME.

Question 2.
Differentiate Unique and Primary Key constraint
Answer:

Unique Key Constraint Primary Key Constraint
The constraint ensures that no two rows have the same value in the specified columns. This constraint declares a field as a Primary Key which helps to uniquely identify a record.
The UNIQUE constraint can be applied only to fields that have also been declared as NOT NULL. The Primary Key does not allow NULL values and therefore a field declared as Primary Key must have the NOT NULL constraint.

Question 3.
Write the difference between table constraint and column constraint?
Answer:
Column constraint:
Column constraints apply only to an individual column.

Table constraint:
Table constraints apply to a group of one or more columns.

Question 4.
Which component of SQL lets insert values in tables and which lets to create a table?
Answer:
Creating a table: CREATE command of DML ( Data Manipulation Language) is used to create a table. Inserting values into tables :
INSERT INTO command of DDL (Data Definition Language) is used to insert values into
the table.

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 5.
What is the difference between SQL and MySQL?
Answer:
SQL-Structured Query Language is a language used for accessing databases while MySQL is a database management system, like SQL Server, Oracle, Informix, Postgres, etc. MySQL is an RDBMS.

III. Answer the following questions (3 Marks)

Question 1.
What is a constraint? Write short note on Primary key constraint.
Answer:
Constraint:

  • Constraint is a condition applicable on a field or set of fields.
  • Constraints are used to limit the type of data that can go into a table.
  • This ensures the accuracy and reliability of the data in the database.
  • Constraints could be either on a column level or a table level.

Primary Constraint:

  • Primly Constraint declares a field as a Primary key which helps to uniquely identify a recor<}ll
  • Primary Constraint is similar to unique constraint except that only one field of a table can be set as primary key.
  • The primary key does not allow NULL values and therefore a field declared as primary key must have the NOT NULL constraint.

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 2.
Write a SQL statement to modify the student table structure by adding a new field.
Answer:
Syntax:
ALTER TABLE < table-name > ADD < column name >< data type >< size > ;
Example:
ALTER TABLE student ADD (age integer (3)).

Question 3.
Write any three DDL commands.
Answer:
a. CREATE TABLE Command
You can create a table by using the CREATE TABLE command.
CREATE TABLE Student
(Admno integer,
Name char(20), \
Gender char(1),
Age integer,
Place char(10),
);

b. ALTER COMMAND
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.
Alter table Student add address char;

c. DROP TABLE:
Drop table command is used to remove a table from the database.
DROP TABLE Student;

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 4.
Write the use of the Savepoint command with an example.
Answer:

  • The SAVEPOINT command is used to temporarily save a transaction so that you can rollback to the point whenever required.
  • The different states of our table can be saved at any time using different names and the rollback to that state can be done using the ROLLBACK command.

Example:
The following is the existing table.
Table 1:

Admno Name Gender Age Place
105 Revathi F 19 Chennai
106 Devika F 19 Bangalore
103 Ayush M 18 Delhi
101 Adarsh M 18 Delhi
104 Abinandh M 18 Chennai

INSERT INTO Student VALUES (107, ‘Beena’, ‘F’, 20, ‘Cochin’);
COMMIT;
In the above table if we apply the above command we will get the following table
Table 2:

Admno Name Gender   Age Place
105 Revathi F 19 Chennai
106 Devika F 19 Bangalore
103 Ayush M 18 Delhi
101 Adarsh M 18 Delhi
104 Abinandh M 18 Chennai
107 Beena F 20 Cochin

We can give save point using the following command.
UPDATE Student SET Name = ‘Mini’ WHERE Admno=105; SAVEPOINT A;

Table 3:

Admno Name Gender Age Place
105 Mini F 19 Chennai
106 Devika F 19 Bangalore
103 Ayush M 18 Delhi
101 Adarsh M 18 Delhi
104 Abinandh M 18 Chennai
107 Beena F 20 Cochin

INSERT INTO Student VALUES(108, ‘Jisha’, ‘F’, 19, ‘Delhi’); SAVEPOINT B;

Table 4:

Admno Name Gender Age Place
105 Mini F 19 Chennai
106 Devika F 19 Bangalore
103 Ayush M 18 Delhi
101 Adarsh M 18 Delhi
104 Abinandh M 18 Chennai
107 Beena F 20 Cochin
108 Jisha F 19 Delhi

After giving the rollback command we will get Table 3 again.

ROLLBACK TO A;
Table 3:

Admno Name Gender Age Place
105 Mini F 19 Chennai
106 Devika F 19 Bangalore
103 Ayush M 18 Delhi
101 Adarsh M 18 Delhi
104 Abinandh M 18 Chennai
107 Beena F 20 Cochin

Question 5.
Write a SQL statement using a DISTINCT keyword.
Answer:
The DISTINCT keyword is used along with the SELECT command to eliminate duplicate rows in the table. This helps to eliminate redundant data.

Example:
SELECT DISTINCT Place FROM Student;
will display the following data as follows :

Place
Chennai
Bangalore
Delhi

IV. Answer the following questions (5 Marks)

Question 1.
Write the different types of constraints and their functions.
Answer:
The different type of constraints are:

  1. Unique Constraint
  2. Primary Key Constraint
  3. Default Constraint
  4. Check Constraint.
  5. Table Constraint:

1. Unique Constraint:

  • This constraint ensures that no two rows have the same value in the specified columns.
  • For example UNIQUE constraint applied on Admno of student table ensures that no two students have the same admission number and the constraint can be used as:

CREATE TABLE Student:
(
Admno integer NOT NULL UNIQUE,→ Unique constraint
Name char (20) NOT NULL,
Gender char (1),
Age integer,
Place char (10)
);

  • The UNIQUE constraint can be applied only to fields that have also been declared as
    NOT NULL.
  • When two constraints are applied on a single field, it is known as multiple constraints.
  • In the above Multiple constraints NOT NULL and UNIQUE are applied on a single field Admno, the constraints are separated by a space and the end of the field definition a comma(,) is added.
  • By adding these two constraints the field Admno must take some value (ie. will not be NULL and should not be duplicated).

2. Primary Key Constraint:

  • This constraint declares a field as a Primary key which helps to uniquely identify a record.
  • It is similar to unique constraint except that only one field of a table can be set as primary key.
  • The primary key does not allow ULI values and therefore a field declared as primary key must have the NOT NULL constraint.

CREATE TABLE Student:
(
Admno integer NOT NULL PRIMARY KEY, → Primary Key constraint
Name char(20)NOT NULL,
Gender char(1),
Age integer,
Place char(10)
);

  • In the above example the Admno field has been set as primary key and therefore will
  • help us to uniquely identify a record, it is also set NOT NULL, therefore this field value cannot be empty.

3. Default Constraint:

  • The DEFAULT constraint is used to assign a default value for the field.
  • When no value is given for the specified field having DEFAULT constraint, automatically the default value will be assigned to the field.
  • Example showing DEFAULT Constraint in the student table:

CREATE TABLE Student:
(
Admno integer NOT NULL PRIMARYKEY,
Name char(20)NOT NULL,.
Gender char(1),
Age integer DEFAULT = “17”, → Default Constraint
Place char(10)
);

In the above example the “Age” field is assigned a default value of 17, therefore when no value is entered in age by the user, it automatically assigns 17 to Age.

4. Check Constraint:

  • Check Constraint helps to set a limit value placed for a field.
  • When we define a check constraint on a single column, it allows only the restricted values on that field.
  • Example showing check constraint in the student table:

CREATE .TABLE Students
(
Admno integer NOT NULL PRIMARYKEY,
Name char(20)NOT NULL,
Gender char(l),
Age integer (CHECK< =19), —> CheckConstraint
Place char(10)
);

In the above example the check constraint is set to Age field where the value of Age must be less than or equal to 19.
The check constraint may use relational and logical operators for condition.

Table Constraint:

  • When the constraint is applied to a group of fields of the table, it is known as the Table constraint.
  • The table constraint is normally given at the end of the table definition.
  • For example, we can have a table namely Studentlwith the fields Admno, Firstname, Lastname, Gender, Age, Place.

CREATE TABLE Student 1:
(
Admno integer NOT NULL,
Firstname char(20),
Lastname char(20),
Gender char(1),
Age integer,
Place char(10),
PRIMARY KEY (Firstname, Lastname) —-Table constraint ‘
);

In the above example, the two fields, Firstname and Lastname are defined as Primary key which is a Table constraint.

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 2.
Consider the following employee table. Write SQL commands for the questions.(i) to (v).

EMP CODE NAME DESIG PAY ALLOWANCE
S1001 Hariharan Supervisor 29000 12000
PI 002 Shaji Operator 10000 5500
PI 003 Prasad Operator 12000 6500
C1004 Manjima Clerk 8000 4500
M1005 Ratheesh Mechanic 20000 7000

Answer:
i) To display the details of all employees in descending order of pay.
SELECT * FROM Employee ORDER BY PAY DESC;
ii) To display all employees whose allowance is between 5000 and 7000.
SELECT FROM Employee WHERE ALLOWANCE BETWEEN 5000 AND 7000;
iii) To remove the employees who are mechanics.
DELETE FROM Employee WHERE DESIG=’Mechanic’;
iv) To add a new row.
INSERT INTO Employee VALUES(/C1006,/ ‘Ram’, ‘Clerk’,15000, 6500);
v) To display the details of all employees who are operators.
SELECT * FROM Employee WHERE DESIG=’Operator’;

Question 3.
What are the components of SQL? Write the commands in each.
Answer:
Components of SQL:
The various components of SQL are

  • Data Definition Language (DDL)
  • Data Manipulation Language (DML)
  • Data Query Language (DQL)
  • Transactional Control Language (TCL)
  • Data Control Language (DCL)

Data Definition Language (DDL):

  • The Data Definition Language (DDL) consists of SQL statements used to define the database structure or schema.
  • It simply deals with descriptions of the database schema and is used to create and modify the structure of database objects in databases.
  • The DDL provides a set of definitions to specify the storage structure and access methods used by the database system.

A DDL performs the following functions:

  • It should identify the type of data division such as data item, segment, record and database file.
  • It gives a unique name to each data item type, record type, file type, and database.
  • It should specify the proper data type.
  • It should define the size of the data item.
  • It may define the range of values that a data item may use.
  • It may specify privacy locks for preventing unauthorized data entry.

SQL commands which come under Data Definition Language are:

Create To create tables in the database.
Alter Alters the structure of the database.
Drop Delete tables from the database.
Truncate Remove all records from a table, also release the space occupied by those records.

Data Manipulation Language:

  • A Data Manipulation Language (DML) is a computer programming language used for adding (inserting), removing (deleting), and modifying (updating) data in a database.
  • In SQL, the data manipulation language comprises the SQL-data change statements, which modify stored data but not the schema of the database table.
  • After the database schema has been specified and the database has been created, the data can be manipulated using a set of procedures which are expressed by DML.

The DML is basically of two types:

  • Procedural DML – Requires a user to specify what data is needed and how to get it.
  • Non-Procedural DML – Requires a user to specify what data are needed without specifying how to get it.

SQL commands which come under Data Manipulation Language are:

Insert Inserts data into a table
Update Updates the existing data within a table
Delete Deletes all records from a table, but not the space occupied by them.

Data Control Language:

  • A Data Control Language (DCL) is a programming language used to control the access of data stored in a database.
  • It is used for controlling privileges in the database (Authorization).
  • The privileges are required for performing all the database operations such as creating sequences, views of tables etc.

SQL commands which come under Data Control Language are:

Grant Grants permission to one or more users to perform specific tasks.
Revoke Withdraws the access permission given by the GRANT statement.

Transactional Control Language:

  • Transactional control language (TCL) commands are used to manage transactions in the database.
  • These are used to manage the changes made to the data in a table by DML statements.

SQL command which comes under Transfer Control Language are:

Commit Saves any transaction into the database permanently.
Rollback Restores the database to the last commit state.
Savepoint Temporarily save a transaction so that you can rollback.

Data Query Language:
The Data Query Language consists of commands used to query or retrieve data from a database.
One such SQL command in Data Query Language is
Select: It displays the records from the table.

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 4.
Construct the following SQL statements in the student table
i) SELECT statement using GROUP BY clause.
ii) SELECT statement using ORDER BY clause.
Table: student

Admno Name / Gender Age Place
100 Ashish M 17 Chennai
101 Adarsh M 18 Delhi
102 Akshith M 17 Bangalore
103 Ayush M 18 Delhi
104 Abinandh M 18 Chennai
105 Revathi F 19 Chennai
106 Devika F 19 Bangalore
107 Hema F 17 Chennai

SELECT statement using GROUP BY clause:

GROUP BY clause:

  • The GROUP BY clause is used with the SELÆCT statement to group the students on rows or columns having identical values or divide the table into groups.
  • For example to know the number of male students or female students of a class, the GROUP BY clause may be used.
  • It is mostly used in conjunction with aggregate functions to produce summary reports from the database.

Syntax for the GROUP BY clause:
SELECT < column-names >FROM GROUP BY HAVING condition;

Example:
To apply the above command on the student table:
SELECT Gender FROM Student GROUP BY Gender;
The following command will give the below-given result:

Gender
M
F

The point to be noted is that only two results have been returned. This is because we only have two gender types ‘Male’ and ‘Female:

  • The GROUP BY clause grouped all the ‘M’ students together and returned only a single row for it. It did the same with the ‘F’ students.
  • For example, to count the number of male and female students in the student table, the following command is given:

SELECT Gender, count(*) FROM Student GROUP BY Gender;

Gender count(*)
M 5
F 3

The GROUP BY applies the aggregate functions independently to a series of groups that are defined by having a field, the value in common. The output of the above SELECT statement gives a count of the number of Male and Female students.

ii) SELECT statement using ORDER BY clause.
ORDER BY clause:

  • The ORDER BY clause in SQL is used to sort the data in either ascending or descending based on one or more columns.
  • By default ORDER BY sorts the data in ascending order.
  • We can use the keyword DESC to sort the data in descending order and the keyword ASC to sort in ascending order.

The ORDER BY clause is used as :
SELECT< column – name1 > ,< column – name2 > , < FROM < table-name > ORDER BY
< column 1 > , < column 2 > ,… ASC | (Pipeline) DESC;

Example: To display the students in alphabetical order of their names, the command is used as
SELECT * FROM Student ORDER BY Name;
The above student table is arranged as follows:

Admno Name Gender Age Place
104 Abinandh M            „ 18 Chennai
101 Adarsh M 18 Delhi
102 Akshith M 17 Bangalore
100 Ashish M 17 Chennai
Admno Name Gender Age Place
103 Ayush M 18 Delhi
106 Devika F 19 Bangalore
107 Hema F 19 Chennai
105 Revathi F 19 Chennai

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 5.
Write a SQL statement to create a table for employees having any five fields and create a table constraint for the employee table.
Answer:
Table: emp
CREATE TABLE emp
(
empno integer NOTNULL,
empfname char(20),
emplname char(20),
Designation char(20),
Basicpay integer,
PRIMARY KEY (empfname,emplname) → Table constraint
);

12th Computer Science Guide International Economics Organisations Additional Important Questions and Answers

I. Choose the best answer (1 Mark)

Question 1.
The SQL was called as …………………….. in the early 1970s.
(a) squel
(b) sequel
(c) seqel
(d) squeal
Answer:
(b) sequel

Question 2.
Which of the following language was designed for managing and accessing data in RDBMS?
a) DBMS
b) DDL
c) DML
d) SQL
Answer:
d) SQL

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 3.
SQL stands for
a) Standard Query Language
b) Secondary Query Language
c) Structural Query Language
d) Standard Question Language
Answer:
c) Structural Query Language

Question 4.
Expand ANSI ………………………
(a) American North-South Institute
(b) Asian North Standard Institute
(c) American National Standard Institute
(d) Artie National Standard Institute
Answer:
(c) American National Standard Institute

Question 5.
The latest SQL standard as of now is
a) SQL 2008
b) SQL 2009
c) SQL 2018
d) SQL 2.0
Answer:
a) SQL 2008

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 6.
In database objects, the data in RDBMS is stored
a) Queries
b) Languages
c) Relations
d) Tables
Answer:
d) Tables

Question 7.
DDL expansion is
a) Data Defined Language
b) Data Definition Language
c) Definition Data Language
d) Dictionary Data Language
Answer:
b) Data Definition Language

Question 8.
Identify which is not an RDBMS package …………………….
(a) MySQL
(b) IBMDB2
(c) MS-Access
(d) Php
Answer:
(d) Php

Question 9.
……………. component of SQL includes commands to insert, delete and modify tables in
database
a) DCL
b) DML
c) TCL
d) DDL
Answer:
b) DML

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 10.
…………………. command removes all records from a table and also release the space occupied by
these records.
a) Drop
b) Truncate
c) ALTER
d) Delete
Answer:
b) Truncate

Question 11.
WAMP stands for
a) Windows, Android, MySQL, PHP
b) Windows, Apache, MySQL, Python
c) Windows, APL, MySQL, PHP
d) Windows, Apache, MySQL, PHP
Answer:
d) Windows, Apache, MySQL, PHP

Question 12.
……………………….. is the vertical entity that contains all information associated with a specific field in a table
(a) Field
(b) tuple
(c) row
(d) record
Answer:
(a) Field

Question 13.
……………. is a collection of related fields or columns in a table.
a) Attributes
b) SQL
c) Record
d) Relations
Answer:
c) Record

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 14.
SQL standard recognized only Text and Number data type.
a) ANSI
b) TCL
c) DML
d) DCL
Answer:
a) ANSI

Question 15.
…………………… data type is same as real expect the precision may exceed 64?
a) float
b) real
c) double
d) long real
Answer:
c) double

Question 16.
………………….. column constraint enforces a field to always contain a value.
a) NULL
b) “NOT NULL”
c) YES
d) ALWAYS
Answer:
b) “NOT NULL”

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 17.
………………… is often used for web development and internal testing.
a) Windows
b) Google
c) WAMP
d) Google Chrome
Answer:
c) WAMP

Question 18.
To work with the databases, the command used is …………………….. database
(a) create
(b) modify
(c) use
(d) work
Answer:
(c) use

Question 19.
………………..is not a SOL TCL command.
a) Commit
b) Rollback
c) Revoke
d) Savepoint
Answer:
c) Revoke

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 20.
………………. provides a set of definitions to specify the storage structure used by the database system.
a) DML
b) DQL
c) DDL
d) TCL
Answer:
c) DDL

Question 21.
Which among the following is not a WAMP?
(a) PHP
(b) MySQL
(c) DHTML
(d) Apache
Answer:
(c) DHTML

Question 22.
…………… command used to create a table.
a) CREATE
b) CREATE TABLE
c) NEW TABLE
d) DDL TABLE
Answer:
b) CREATE TABLE

Question 23.
……………….. keyword is used to sort the records in ascending order.
a) ASCD
b) ASD
c) ASCE
d) ASC
Answer:
d) ASC

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 24.
Which command changes the structure of the database?
(a) update
(b) alter
(c) change
(d) modify
Answer:
(b) alter

Question 25.
………………… clause is used to divide the table into groups.
a) DIVIDE BY
b) ORDER BY
c) GROUP BY
d) HAVING
Answer:
c) GROUP BY

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 26.
……………. command is used to gives permission to one or more users to perform specific tasks.
a) GIVE
b) ORDER
c) GRANT
d) WHERE
Answer:
c) GRANT

Question 27.
How many types of DML commands are there?
(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(b) 2

II. Answer the following questions (2 and 3 Marks)

Question 1.
Write a note on RDBMS?
Answer:
RDBMS stands for Relational Database Management System. Oracle, MySQL, MS SQL Server, IBM DB2, and Microsoft Access are RDBMS packages. RDBMS is a type of DBMS with a row-based table structure that connects related data elements and includes functions related to Create, Read, Update and Delete operations, collectively known as CRUD.

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 2.
What is SQL?
Answer:

  • The Structured Query Language (SQL) is a standard programming language to access and manipulate databases.
  • SQL allows the user to create, retrieve, alter, and transfer information among databases.
  • It is a language designed for managing and accessing data in a Relational Database Management System (RDBMS).

Question 3.
What are the 2 types of DML?
Answer:
The DML is basically of two types:
Procedural DML – Requires a user to specify what data is needed and how to get it. Non-Procedural DML – Requires a user to specify what data are needed without specifying how to get it.

Question 4.
How can you create the database and work with the database?
Answer:

  • To create a database, type the following command in the prompt:
  • CREATE DATABASE database_name;
  • Example; To create a database to store the tables:
    CREATE DATABASE stud;
  • To work with the database, type the following command.
    USE DATABASE;
  • Example: To use the stud database created, give the command USE stud;

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 5.
Write short notes on WAMP?
Answer:
WAMP stands for “Windows, Apache, MySQL, and PHP” It is often used for web development and internal testing, but may also be used to serve live websites.

Question 6.
Write a SQL statement to create a table for employees having any five fields and create a table constraint for the employee table. (March 2020)
Answer:
Employee Table with Table Constraint:
CREATE TABLE Employee(EmpCode Char(5) NOT NULL, Name Char(20) NOT NULL, Desig Char(1O), Pay float(CHECK>=8000), Allowance float PRIMARY KEY(EmpCode,Name));

Question 7.
Explain DDL commands with suitable examples.
Answer:
DDL commands are

  • Create
  • Alter
  • Drop
  • Truncate

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Create: To create tables in the database.

Syntax:
CREATE TABLE < table-name >
( < column name >< data type > [ < size > ]
( < column name >< data type > [ < size > ]…
);
Example:
CREATE TABLE Student
(
Admno integer NOT NULL PRIMARY KEY,
Name char(20)NOT NULL,
Gender char(1),
Age integer DEFAULT = “17” → Default
Constraint
Place char(10),
);

Alter:
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:

ALTER TABLE ADD
< data type >< size > ;

  • To add a new column <<Address>> of type to the Student table, the command is used as
    ALTER TABLE Student ADD Address char;
  • To modify, an existing column of the table, the ALTER TABLE command can be used with MODIFY clause likewise:
    ALTER < table-name > MODIFY < data type >< size >;
    ALTER TABLE Student MODIFY Address char (25);
    Drop: Delete tables from the database.
  • The DROP TABLE command is used to remove a table from” the database.
  • After dropping a table all the rows in the table is deleted and the table structure is removed from the database.
  • Once a table is dropped we cannot get it back. But there is a condition for dropping a table; it must be an empty table.
  • Remove all the rows of the table using the DELETE command.
  • To delete all rows, the command is given as;
    DELETE FROM Student;
  • Once all the rows are deleted, the table can be deleted by the DROP TABLE command in the following way:
    DROP TABLE table-name;
  • Example: To delete the Student table:
    DROP TABLE Student;
  • Truncate: Remove all records from a table, also release the space occupied by those records.
  • The TRUNCATE command is used to delete all the rows from the table, the structure remains and space is freed from the table.
  • The syntax for the TRUNCATE command is: TRUNCATE TABLE table-name;

Example:
To delete all the records of the student table and delete the table the SQL statement is given as follows:
TRUNCATE TABLE Student;
The table Student is removed and space is freed.

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 8.
Write a note on SQL?
Answer:

  1. The Structured Query Language (SQL) is a standard programming language to access and manipulate databases.
  2. SQL allows the user to create, retrieve, alter, and transfer information among databases.
  3. It is a language designed for managing and accessing data in a Relational Database Management System (RDBMS).

Question 9.
Write short notes on basic types of DML.
Answer:
The DML is basically of two types:

  • Procedural DML – Requires a user to specify what data is needed and how to get it.
  • Non-Procedural DML – Requires a user to specify what data is needed without specifying how to get it.

Question 10.
Explain DML commands with suitable examples.
Answer:
i) INSERT:
insert: Inserts data into a table
Syntax:
INSERT INTO < table-name > [column-list] VALUES (values); Example:
INSERT INTO Student VALUES(108, ‘Jisha’, ‘F, 19, ‘Delhi’);

ii) DELETE:
Delete: Deletes all records from a table, but not the space occupied by them. Syntax:
DELETE FROM table-name WHERE condition;
Example:
DELETE FROM Employee WHERE DESIG=’Mechanic’;

iii) UPDATE:
Update: Updates the existing data within a table.

Syntax:
UPDATE < table-name > SET column- name = value, column-name = value,..
WHERE condition;
Example:
UPDATE Student SET Name = ‘Mini’
WHERE Admno=105;

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 11.
What are the various processing skills of SQL?
Answer:
The various processing skills of SQL are:

  1. Data Definition Language (DDL): The SQL DDL provides commands for defining relation schemes (structure), deleting relations, creating indexes, and modifying relation schemes.
  2. Data Manipulation Language (DML): The SQL DML includes commands to insert, delete, and modify tuples in the database.
  3. Embedded Data Manipulation Language: The embedded form of SQL is used in high-level programming languages.
  4. View Definition: The SQL also includes commands for defining views of tables.
  5. Authorization: The SQL includes commands for access rights to relations and views of tables.
  6. Integrity: SQL provides forms for integrity checking using conditions.
  7. Transaction control: The SQL includes commands for file transactions and control over transaction processing.

Question 12.
Write short notes on DCL (Data Control Language).
Answer:
Data Control Language (DCL): Data Control Language (DCL) is a programming language used to control the access of data stored in a database.

DCL commands:

  • Grant Grants permission to one or more users to perform specific tasks
  • Revoke: Withdraws the access permission given by the GRANT statement.

Question 13.
Write short notes on Data Query Language(DQL).
Answer:

  • The Data Query Language consists of commands used to query or retrieve data from a database.
  • One such SQL command in Data Query Language is ‘1Select” which displays the records from the table.

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 14.
How will you retain duplicate rows of a table?
Answer:
The ALL keyword retains duplicate rows. It will display every row of the table without considering duplicate entries
SELECT ALL Place FROM Student;

Question 15.
What are the functions performed by DDL?
Answer:
A DDL performs the following functions :

  1. It should identify the type of data division such as data item, segment, record, and database file.
  2. It gives a unique name to each data item type, record type, file type, and database.
  3. It should specify the proper data type.
  4. It should define the size of the data item.
  5. It may define the range of values that a data item may use.
  6. It may specify privacy locks for preventing unauthorized data entry.

Question 16.
Differentiate IN and NOT IN keywords.
Answer:
IN Keyword:

  • The IN keyword is used to specify a list of values which must be matched with the record values.
  • In other words, it is used to compare a column with more than one value.
  • It is similar to an OR condition.

NOT IN keyword:
The NOT IN keyword displays only those records that do not match in the list

Question 17.
Explain Primary Key Constraint with suitable examples.
Answer:

  • This constraint declares a field as a Primary key which, helps to uniquely identify a record.
  • It is similar to a unique constraint except that only one field of a table can be set as the primary key.
  • The primary key does not allow ULI values and therefore a field declared as the primary key must have the NOT NULL constraint.

CREATE TABLE Student:
(
Admno integer
NOT NULL PRIMARYKEY,→
Primary Key constraint
Name char(20)NOT NULL,
Gender char(1),
Age integer,
Place char(10)
);

In the above example, the Admno field has been set as the primary key and therefore will help us to uniquely identify a record, it is also set NOT NULL, therefore this field value cannot be empty.

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 18.
Explain GROUP BY and HAVING clauses.
Syntax:
SELECT < column-names > FROM GROUP BY < column-name > HAVING condition;
The HAVING clause can be used along with the GROUP BY clause in the SELECT statement to place conditions on groups and can include aggregate functions on them.

Example:
To count the number of Male and Female students belonging to Chennai. SELECT Gender, count( *) FROM Student GROUP BY Gender HAVING Place = ‘Chennai’,

Question 19.
List the data types used in SQL.
Answer:
Data types used in SQL:

  • char (Character)
  • varchar
  • dec (Decimal)
  • Numeric
  • int (Integer)
  • Small int
  • Float
  • Real
  • double

Question 20.
Write notes on a predetermined set of commands of SQL?
Answer:
A predetermined set of commands of SQL:
The SQL provides a predetermined set of commands like Keywords, Commands, Clauses, and Arguments to work on databases.

Keywords:

  • They have a special meaning in SQL.
  • They are understood as instructions.

Commands:
They are instructions given by the user to the database also known as statements

Clauses:
They begin with a keyword and consist of keyword and argument

Arguments:
They are the values given to make the clause complete.

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

Question 21.
Explain how to set a primary key for more than one field? Explain with example.
Answer:
Table Constraint:

  • When the constraint is applied to a group of fields of the table, it is known as the Table constraint.
  • The table constraint is normally given at the end of the table definition.
  • For example, we can have a table namely Studentlwith the fields Admno, Firstname, Lastname, Gender, Age, Place.

CREATE TABLE Student 1:
(
Admno integer NOT NULL,
Firstname char (20),
Lastname char(20),
Gender char(1),
Age integer,
Place char(10),
PRIMARY KEY (Firstname, Lastname) → Table constraint);

In the above example, the two fields, Firstname and Lastname are defined as Primary key which is a Table constraint.

Question 22.
Explain how to generate queries and retrieve data from the table? Explain?
Answer:

  • 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:
SELECT < column-list > FROM < table-name >;

  • Table-name is the name of the table from which the information is retrieved.
  • Column-list includes one or more columns from which data is retrieved.

Samacheer Kalvi 12th Computer Science Guide Chapter 12 Structured Query Language (SQL)

III. Answer the following questions (5 Marks)

Question 1.
Write the processing skills of SQL.
Answer:
The various processing skills of SQL are:

  • Data Definition Language (DDL): The SQL DDL provides commands for defining relation schemas (structure), deleting relations, creating indexes, and modifying relation schemas.
  • Data Manipulation Language (DML): The SQL DML includes commands to insert, delete, and modify tuples in the database.
  • Embedded Data Manipulation Language: The embedded form of SQL is used in high-level programming languages.
  • View Definition: The SQL also includes commands for defining views of tables
  • Authorization: The SQL includes commands for access rights to relations and views of tables.
  • Integrity: SQL provides forms for integrity checking using conditions.
  • Transaction control: The SQL includes commands for file transactions and control over transaction processing.

Question 2.
Explain ALTER command in detail.
Answer:
ALTER command:
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:
ALTER TABLE ADD < data type >< size >;

To add a new column «Address» of type to the Student table, the command is used as
ALTER TABLE Student ADD Address char;

To modify, an existing column of the table, the ALTER TABLE command can be used with MODIFY clause likewise:
ALTER < table-name > MODIFY < data type>< size>;
ALTER TABLE Student MODIFY Address char (25); The above command will modify the address column of the Student table to now hold 25 characters.
The ALTER command can be used to rename an existing column in the following way:
ALTER < table-name > RENAME oldcolumn- name TO new-column-name;

Example:

  • To rename the column Address to City, the command is used as:
    ALTER TABLE Student RENAME Address TO City;
  • The ALTER command can also be used to remove a column .or all columns.

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 DROP COLUMN;
  • To remove the column City from the Student table. the command is used as ALTER. TABLE Student DROP COLUMN City;

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Tamilnadu State Board New Syllabus Samacheer Kalvi 12th Economics Guide Pdf Chapter 8 International Economic Organisations Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 12th Economics Solutions Chapter 8 International Economic Organisations

12th Economics Guide International Economic Organisations Text Book Back Questions and Answers

PART – A

Multiple Choice questions

Question 1.
International Monetary Fund was an outcome of
a) Pandung conference
b) Dunkel Draft
c) Bretton woods conference
d) Doha conference
Answer:
c) Bretton woods conference

Question 2.
International Monetary Fund is having its headquarters at
a) Washington D. C.
b) Newyork
c) Vienna
d) Geneva
Answer:
a) Washington D. C.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 3.
IBRD is otherwise called
a) IMF
b) World bank
c) ASEAN
d) International Finance corporation
Answer:
b) World bank

Question 4.
The other name for Special Drawing Right is
a) Paper gold
b) Quotas
c) Voluntary Export Restrictions
d) None of these.
Answer:
a) Paper gold

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 5.
The organization which provides long term loan is
a) World Bank
b) International Monetary Fund
c) World Trade Organization
d) BRICS
Answer:
a) World Bank

Question 6.
Which of the following countries is not a member of SAARC?
a) Sri Lanka
b) Japan
c) Bangladesh
d) Afghanistan
Answer:
b) Japan

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 7.
International Development Association is an affiliate of
a) IMF
b) World Bank
c) SAARC
d) ASEAN
Answer:
b) World Bank

Question 8.
………………………….. relates to patents, copyrights, trade secrets, etc.,
a) TRIPS
b) TRIMS
c) GATS
d) NAMA
Answer:
a) TRIPS

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 9.
The first ministerial meeting of WTO was held at
a) Singapore
b) Geneva
c) Seattle
d) Doha
Answer:
a) Singapore

Question 10.
ASEAN meetings are held once in every ……………….. years
a) 2
b) 3
c) 4
d) 5
Answer:
b) 3

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 11.
Which of the following is not member of SAARC?
a) Pakistan
b) Sri lanka
c) Bhutan
d) China
Answer:
d) China

Question 12.
SAARC meets once in ……………………………. years.
a) 2
b) 3
c) 4
d) 5
Answer:
a) 2

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 13.
The headquarters of ASEAN is
a) Jaharta
b) New Delhi
c) Colombo
d) Tokyo
Answer:
a) Jaharta

Question 14.
The term RRIC was coined in
a) 2001
b) 2005
c) 2008
d) 2010
Answer:
a) 2001

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 15.
ASEAN was created in
a) 1965
b) 1967
c) 1972
d) 1997
Answer:
b) 1967

Question 16.
The Tenth BRICS summit was held in July 2018 at
a) Beijing
b) Moscow
c) Johannesburg
d) Brasilia
Answer:
c) Johannesburg

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 17.
New Development Bank is associated with.
a) BRICS
b) WTO
c) SAARC
d) ASEAN
Answer:
a) BRICS

Question 18.
Which of the following does not come under ‘ six dialogue partners’ of ASEAN? .
a) China
b) Japan
c) India
d) North Korea
Answer:
d) North Korea

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 19.
SAARC Agricultural Information centre ( SAIC ) works as a central informa¬tion institution for agriculture related resources was founded on.
a) 1985
b) 1988
c) 1992
d) 1998
Answer:
b) 1988

Question 20.
BENELUX is a form of
a) Free trade area
b) Economic Union
c) Common market
d) Customs union
Answer:
d) Customs union

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

PART-B

Answer the following questions in one or two sentences.

Question 21.
Write the meaning of Special Drawing Rights.
Answer:

  1. The Fund has succeeded in establishing a scheme of Special Drawing Rights (SDRs) which is otherwise called ‘Paper Gold’.
  2. They are a form of international reserves created by the IMF in 1969 to solve the problem of international liquidity.
  3. They are allocated to the IMF members in proportion to their Fund quotas.
  4. SDRs are used as a means of payment by Fund members to meet the balance of payments deficits and their total reserve position with the Fund.
  5. Thus SDRs act both as an international unit of account and a means of payment.
  6. All transactions by the Fund in the form of loans and their repayments, its liquid reserves, its capital, etc., are expressed in the SDR.

Question 22.
Mention any two objectives of ASEAN.
Answer:

  1. To accelerate the economic growth, social progress, and cultural development in the region.
  2. To promote regional peace and stability and adherence to the principles of the United Nations charter.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 23.
Point out any two ways in which IBRD lends to member countries.
Answer:
The Bank advances loans to members in two ways

  1. Loans out of its own fund,
  2. Loans out of borrowed capital.

Question 24.
Define common Market.
Answer:
Common market is a group formed by countries with in a geographical area to promote duty free trade and free movement of labour and capital among its members.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 25.
What is Free trade area?
Answer:
Free trade area is the region encompassing a trade bloc whose member countries have signed a free trade agreement.

Question 26.
When and where was SAARC secretariat established?
Answer:
South Asian Association For Regional Co-Operation (SAARC):
1. The South Asian Association for Regional Cooperation (SAARC) is an organisation of South Asian nations, which was established on 8 December 1985 for the promotion of economic and social progress, cultural development within the South Asia region, and also for friendship and cooperation with other developing countries.

2. The SAARC Group (SAARC) comprises of Bangladesh, Bhutan, India, The Maldives, Nepal, Pakistan and Sri Lanka.

3. In April 2007, Afghanistan became its eighth member.

Question 27.
Specify any two affiliates of world Bank Group. (Write any 2)
Answer:

  1. International Bank for Reconstruction and Development (IBRD)
  2. International Development Association (IDA)
  3. International Finance corporation (IFC)
  4. Multilateral Investment Guarantee Agency (MIGA)
  5. The International centre for settlement of Investment Disputes (ICSID)

PART – C

Answer the following questions in one paragraph.

Question 28.
Mention the various forms of economic integration.
Answer:
Economic integration takes the form of

  • A free Trade Area: It is the region encompassing a trade bloc whose member countries have signed a free trade agreement.
  • A customs union: It is defined as a type of trade bloc which is composed of a free trade area with no tariff among members and with a common external tariff.
  • Common market: It is established through trade pacts. A group formed by coun-tries within a geographical area to promote duty-free trade and free movement of labour and capital among its members.
  • An economic union: It is composed of a common market with a customs union.

Question 29.
What are trade blocks?
Answer:
1. Trade blocks cover different kinds of arrangements between or among countries for mutual benefit. Economic integration takes the form of Free Trade Area, Customs Union, Common Market and Economic Union.

2. A free trade area is the region encompassing a trade bloc whose member countries have signed a free-trade agreement (FTA). Such agreements involve cooperation between at least two countries to reduce trade barriers, e.g. SAFTA, EFTA.

3. A customs union is defined as a type of trade block which is composed of a free trade area with no tariff among members and (zero tariffs among members) with a common external tariff, e.g. BENELUX (Belgium, Netherland and Luxumbuarg).

4. Common market is established through trade pacts. A group formed by countries within a geographical area to promote duty free trade and free movement of labour and capital among its members, e.g. European Common Market (ECM).

5. An economic union is composed of a common market with a customs union. The participant countries have both common policies on product regulation, freedom of movement of goods, services and the factors of production and a common external trade policy. (e.g. European Economic Union).

Question 30.
Mention any three lending programmes of IMF.
Answer:
The Fund has created several new credit facilities for its members.

1. Extended Fund Facility:
Under this arrangement, the IMF provides additional borrowing facility up to 140% of the member’s quota, over and above the basic credit facility. The extended facility is limited for a period up to 3 years and the rate of interest is low.

2. Buffer Stock Facility:
The Buffer stock financing facility was started in 1969. The purpose of this scheme was to help the primary goods producing countries to finance contributions to buffer stock arrangements for the establisation of primary product prices.

3. Supplementary Financing Facility :
Under the supplementary financing facility, the IMF makes temporary arrange-ments to provide supplementary financial assistance to member countries facing payments problems relating to their present quota sizes.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 31.
What is a Multilateral Agreement?
Answer:
Multilateral trade agreement:
It is a multinational legal or trade agreements between countries. It is an agreement between more than two countries but not many. The various agreements implemented by the WTO such as TRIPS, TRIMS, GATS, AoA, MFA have been discussed.

Question 32.
Write the agenda of BRICS summit, 2018.
Answer:
South Africa hosted the 10th BRICS summit in July 2018. The agenda for the BRICS summit 2018 includes Inclusive growth, Trade issues, Global governance, shared prosperity, International peace, and security.

Question 33.
State briefly the functions of SAARC.
Answer:
The main functions of SAARC are as follows.

  1. Maintenance of the cooperation in the region
  2. Prevention of common problems associated with the member nations.
  3. Ensuring strong relationships among the member nations.
  4. Removal of poverty through various packages of programmes.
  5. Prevention of terrorism in the region.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 34.
List but the achievements of ASEAN.
Answer:

  • The main achievement of ASEAN has been the maintenance of an uninterrupted period of peace and stability during which the individual member countries have been able to concentrate on promoting rapid and sustained economic growth and modernization.
  • ASEAN’S modernization efforts have brought about changes in the region’s structure of production.
  • ASEAN has been the fourth largest trading entity in the world after the European Union the United States and Japan.

PART – D

Answer the following questions in about a page.

Question 35.
Explain the objectives of IMF.
Answer:
Objectives Of IMF:

  1. To promote international monetary cooperation among the member nations.
  2. To facilitate faster and balanced growth of international trade.
  3. To ensure exchange rate stability by curbing competitive exchange depreciation.
  4. To eliminate or reduce exchange controls imposed by member nations.
  5. To establish multilateral trade and payment system in respect of current transactions instead of bilateral trade agreements.
  6. To promote the flow of capital from developed to developing nations.
  7. To solve the problem of international liquidity.

Question 36.
Bring out the functions of the World Bank.
Answer:
Investment for productive purposes :
The world Bank performs the function of assisting in the reconstruction and development of territories of member nations through the facility of investment for productive purposes.

Balance growth of international trade :
Promoting the long-range balanced growth of trade at the international level and maintaining equilibrium in BOPS of member nations by encouraging international investment.

Provision of loans and guarantees :
Arranging the loans or providing guarantees on loans by various other channels so as to execute important projects.

Promotion of foreign private investment:
The promotion of private foreign investment by means of guarantees on loans and other investments made by private investors. The Bank supplements private investment by providing finance for productive purposes out of its own resources or from borrowed funds.

Technical services:
The world Bank facilitates different kinds of technical services to the member countries through staff college and exports.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 37.
Discuss the role of WTO in India’s socio-economic development.
Answer:
WTO and India:
India is the founding member of the WTO. India favours a multilateral trade approach. It enjoys MFN status and allows the same status to all other trading partners. India benefited
from WTO on the following grounds:

  1. By reducing tariff rates on raw materials, components and capital goods, it was able to import more for meeting her developmental requirements. India’s imports go on increasing.
  2. India gets market access in several countries without any bilateral trade agreements.
  3. Advanced technology has been obtained at cheaper cost.
  4. India is in a better position to get quick redressal from trade disputes.
  5. The Indian exporters benefited from wider market information.

Question 38.
Write a note on a) SAARC b) BRICS
Answer:
(a) South Asian Association For Regional Co-Operation (SAARC):

  • The South Asian Association for Regional Cooperation (SAARC) is an organisation of South Asian nations, which was established on 8 December 1985 for the promotion of economic and social progress, cultural development within the South Asia region, and also for friendship and co-operation with other developing countries.
  • The SAARC Group (SAARC) comprises Bangladesh, Bhutan, India, The Maldives, Nepal, Pakistan, and Sri Lanka.
  • In April 2007, Afghanistan became its eighth member.
  • The basic aim of the organisation is to accelerate the process of economic and social development of member states through joint action in the agreed areas of cooperation.
  • The SAARC Secretariat was established in Kathmandu (Nepal) on 16th January 1987.
  • The first SAARC summit was held in Dhaka in the year 1985.
  • SAARC meets once in two years. Recently, the 20th SAARC summit was hosted by Srilanka in 2018.

(b) BRICS:

  • BRICS is the acronym for an association of five major emerging national economies: Brazil, Russia, India, China and South Africa.
  • Since 2009, the BRICS nations have met annually at formal summits.
  • South Africa hosted the 10th BRICS summit in July 2018.
  • The agenda for the BRICS summit 2018 includes Inclusive growth, Trade issues, Global governance, Shared Prosperity, International peace, and security.
  • Its headquarters is in Shanghai, China.
  • The New Development Bank (NDB) formerly referred to as the BRICS Development Bank was established by the BRICS States.
  • The first BRICS summit was held in Moscow and South Africa hosted the Tenth Conference at Johanesberg in July 2018.
  • India had an opportunity of hosting the fourth and Eighth summits in 2009 and 2016 respectively.
  • The BRICS countries make up 21 percent of the global GDP. They have increased their share of global GDP threefold in the past 15 years.
  • The BRICS are home to 43 percent of the world’s population.
  • The BRICS countries have combined foreign reserves of an estimated $ 4.4 trillion.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

12th Economics Guide International Economics Organisations Additional Important Questions and Answers

I. Choose the best Answer

Question 1.
The IMF has ……………………. member countries with Republic.
(a) 169
(b) 179
(c) 189
(d) 199
Answer:
(c) 189

Question 2.
The IMF and World Bank were started in ………
a) 1947
b) 1951
c) 1945
d) 1954
Answer:
c) 1945

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 3.
At present, the IMF has ………….member countries.
a) 198
b) 189
c) 179
d) 197
Answer:
b) 189

Question 4.
International Monetary Fund headquarters are present in …………………….
(a) Geneva
(b) Washington DC
(c) England
(d) China
Answer:
(b) Washington DC

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 5.
SDR stands for ………………
a) IMF
b) IBRD
c) Special Drawing Rights
d) World Trade Organization
Answer:
c) Special Drawing Rights

Question 6.
SDR was created on ………………….
a) 1950
b) 1951
c) 1969
d) 1967
Answer:
c) 1969

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 7.
The name “International Bank for Reconstruction and Development” was first suggested by
a) India
b) America
c) England
d) France
Answer:
a) India

Question 8.
Special Drawing called …………………….
(a) Gold
(b) Metal
(c) Paper Gold
(d) Gold Paper
Answer:
(c) Paper Gold

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 9.
The first WTO conference was held in Singapore in …………………
a) 1991
b) 1995
c) 1996
d) 1999
Answer:
c) 1996

Question 10.
It was planned to organize 12 th ministerial conference at ………………
a) Pakistan
b) Kazakhstan
c) Afghanistan
d) Washington
Answer:
b) Kazakhstan

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 11.
IBRD otherwise called the …………………….
(a) IMF
(b) SDR
(c) SAF
(d) World Bank
Answer:
(d) World Bank

Question 12.
BRICS was established in …………….
a) 1985
b) 2001
c) 1967
d)1951
Answer:
b) 2001

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 13.
The BRICS are home to …………………. percent of the world’s population.
a) 45
b) 43
c) 44
d) 21
Answer:
b) 43

Question 14.
The headquarters of SAARC is at ………………
a) Jakarta
b) Shangai
c) Washington
d) Kathmandu
Answer:
d) Kathmandu

Question 15.
The IBRD has ……………………. member countries.
(a) 159
(b) 169
(c) 179
(d) 189
Answer:
(d) 189

Question 16.
……………………. governed the world trade in textiles and garments since 1974.
(a) GATS
(b) GATT
(c) MFA
(d) TRIPS
Answer:
(c) MFA

Question 17.
Agriculture was included for the first time under …………………….
(a) GATS
(b) GATT
(c) MFA
(d) TRIMs
Answer:
(b) GATT

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

II. Match the Following

Question 1.
A) Bretton woods conference – 1) 1945
B) World Trade Organisation – 2) 1944
C) International Monetary Fünd – 3)1930
D) Great Economic Depression – 4)1995
Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations 1
Answer:
a) 2 4 1 3

Question 2.
A) SAARC – 1) Washington D.C
B) ASEAN – 2) Kathmandu
C) BRICS – 3) Jakarta
D) IMF – 4) Shangai
Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations 2
Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations 3

Answer:
c) 2 3 4 1

Question 3.
A) Free trade area – 1) European Economic Union
B) Customs union – 2) SAFTA
C) Common market – 3) BENELUX
D) Economic union – 4) European Common Market
Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations 4
Answer:
b) 2 3 4 1

III. Choose the correct pair :

Question 1.
a) SAARC – December 8, 1988
b) ASEAN – August 8, 1977
c) IBRD – 1944
d) BRIC – 2001
Answer:
d) BRIC – 2001

Question 2.
a) 189th member country of IMF – Republic of Nauru
b) Structural Adjustment facility – Paper Gold
c) First Conference of WTO – 1996, Malaysia
d) TRIPS – 1998
Answer:
a) 189th member country of IMF – Republic of Nauru

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 3.
a) SAARC preferential Trading Agreement – EFTA
b) SAARC Agricultural Information centre – SAIC
c) South Asian Development Fund – SADF
d) European Economic union – EEU
Answer:
d) European Economic union – EEU

IV. Choose the Incorrect Pair:

Question 1.
a) International Monetary Fund – Exchange rate stability
b) Special Drawing Rights – Paper Gold
c) Structural Adjustment Facility – Balance of payment assistance
d) Buffer stock Financing facility – 1970
Answer:
d) Buffer stock Financing facility – 1970

Question 2.
a) International Bank for – World Bank Reconstruction and Development
b) World Bank Group – World Trade Organisation
c) India became a member of MIGA – January 1994
d) WTO – Liberalizing trade restrictions
Answer:
b) World Bank Group – World Trade Organisation

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 3.
a) IGA, ICSID, IDA, IFC – World. Bank Group
b) Brazil, Russia, India, China, South Africa – BRICS
c) Pakistan, Nepal, Afghanistan, Bangladesh, India, Srilanka – ASEAN
d) WTO Agreements – TRIPS, TRIMS
Answer:
c) Pakistan, Nepal, Afghanistan, Bangladesh, India, Srilanka – ASEAN

V. Choose the correct Statement

Question 1.
a) The IMF and World Bank were started in 1944
b) The GATT was transformed into WTO in 1995.
c) The headquarters of the World Trade Organization is in Geneva.
d) the Republic of Nauru joined IMF in 2018.
Answer:
c) The headquarters of the World Trade organization is in Geneva.

Question 2.
a) ‘International Monetary Fund is like an International Reserve Bank’ – Milton Fried man
b) IMF established compensatory Financing Facility in 1963.
c) In December 1988 the IMF set up the Enhanced Structural Adjustment Facility (ESAF)
d) India is the sixth-largest member of the IMF.
Answer:
b) IMF established a compensatory Financing Facility in 1963.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 3.
a) SDR is the Fiat Money of the IMF.
b) The membership in IMF is not a prerequisite to becoming a member of IBRD
c) India is a member of World Bank’s International center for settlement of Investment Disputes.
d) First investment of IFC in India took place in 1960.
Answer:
a) SDR is the Fiat Money of the IMF.

VI. Choose the Incorrect Statement

Question 1.
a) The IBRD was established to provide long-term financial assistance to member countries.
b) The IBRD has 190 member countries.
c) India become a member of MIGA in January 1994.
d) India is one of the founder members of IBRD, IDA, and IFC.
Answer:
b) The IBRD has 190 member countries.

Question 2.
a) Intellectual property rights include copyright, trademarks, patents, geographical indications, etc.
b) TRIMS are related to conditions or restrictions in respect of foreign investment in the country.
c) Phasing out of Multi Fibre Agreement (MFA) by WTO affected India.
d) It is mandatory for the Dispute Settlement Body to settle any dispute within 18 months.
Answer:
c) Phasing out of Multi Fibre Agreement (MFA) by WTO affected India.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 3.
a) The SAARC group comprises Bangladesh, Bhutan, India, The Maldives, Nepal, Pakistan, and Sri Lanka.
b) An economic union is composed of a common market with a customs union.
c) Afghanistan joined SAARC on 3rd April 2007.
d) The 20th SAARC summit was held in Dhaka.
Answer:
d) The 20th SAARC Summit was held in Dhaka.

VII. Pick the odd one out:

Question 1.
a) Trade Association
b) Free trade Area
c) Custom union
d) Common market
Answer:
a) Trade Association

Question 2.
a) ASEAN
b) BRICS
c) SAARC
d) SDR
Answer:
d) SDR

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 3.
a) IFC
b) MIGA
c) ASEAN
d) ICSID
Answer:
c) ASEAN

VIII. Analyse the Reason

Question 1.
Assertion (A): The IBRD was established to provide long-term financial assistance to member countries.
Reason (R): World bank helps its member countries with economic reconstruction and development.
Answer:
a) Assertion (A) and Reason (R) both are true, and (R) is the correct explanation of (A).

Question 2.
Assertion (A): TRIPS Agreement provides for granting product patents instead of process patents.
Reason (R): Intellectual property rights include copyright, trademark, patents, geographical indications, etc.
Answer:
b) Assertion (A) and Reason (R) both are true, but (R) is not the correct explanation of (A).
Options:
a) Assertion (A) and Reason (R) both are true, and (R) is the correct explanation of (A).
b) Assertion (A) and Reason (R) both are true, but (R) is not the correct explanation of (A).
c) Assertion (A) and Reason (R) both are false.
d) (A) is true but (R) is false.

IX. Two Mark Questions

Question 1.
Write IMF Functions group?
Answer:
The functions of the IMF are grouped under three heads.

  1. Financial – Assistance to correct short and medium Tenn deficit in BOP;
  2. Regulatory – Code of conduct and
  3. Consultative – Counseling and technical consultancy.

Question 2.
What are the major functions of WTO?
Answer:

  1. Administering WTO trade agreements
  2. Forum for trade negotiations
  3. Handling trade disputes
  4. Monitoring national trade policies
  5. Technical assistance and training for developing countries.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 3.
Write the World bank activities of Rural areas?
Answer:
The bank now also takes interest in the activities of the development of rural areas such as:

  1. Spread of education among the rural people
  2. Development of roads in rural areas and
  3. Electrification of the villages.

Question 4.
What is a customs union?
Answer:
A customs union is defined as a type of trade bloc which is composed of a free trade area with no tariff among members and with a common external tariff.

Question 5.
Define World Trade Organisation?
Answer:

  1. WTC headquarters located at New York, USA.
  2. It featured the landmark Twin Towers which was established on 4th April 1973.
  3. Later it was destroyed on 11th September 2001 by the craft attack.
  4. It brings together businesses involved in international trade from around the globe.

Question 6.
What are TRIPS?
Answer:
Trade-Related Intellectual Property Rights (TRIPs). Which include copyright, trademarks, patents, geographical indications, industrial designs, and the invention of microbial plants.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 7.
What are trade blocks?
Answer:
Trade blocks are a set of countries that engage in international trade together and are usually related through a free trade agreement or other associations.

Question 8.
Who are “dialogue partners”?
Answer:
The ASEAN, there are six “dialogue partners” which have been participating in its deliberations. They are China, Japan, India, South Korea, New Zealand, and Australia.

Question 9.
In how many constituents of the World Bank group India become a member?
Answer:
India is a member of four of the five constituents of the World Bank Group.

  1. International Bank for Reconstruction and Development.
  2. International Development Association.
  3. International Finance Corporation.
  4. Multilateral Investments Guarantee Agency

Question 10.
What is SDR?
Answer:

  • SDR is the Fiat Money of the IMF.
  • A potential claim on underlying currency Basket.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 11.
Why was the SDR created?
Answer:

  • To be “The” World Reserve Currency
  • Create Global Liquidity.

Question 12.
How is the SDR valued?
Answer:
“The value of the SDR was initially defined as equivalent to 0.888671 grams of fine gold – which, at the time was also equivalent to one US dollar.

X. 3 Mark Questions

Question 1.
Brief notes on India and IMF?
Answer:
India and IMF:

  1. Till 1970, India stood fifth in the Fund and it had the power to appoint a permanent Executive Director.
  2. India has been one of the major beneficiaries of the Fund assistance.
  3. It has been getting aid from the various Fund Agencies from time to time and has been regularly repaying its debt.
  4. India’s current quota in the IMF is SDRs (Special Drawing Rights) 5,821.5 million, making it the 13th largest quota holding country at IMF with shareholdings of 2.44%.
  5. Besides receiving loans to meet the deficit in its balance of payments, India has benefited in certain other respects from the membership of the Fund.

Question 2.
What are the achievements of IMF?
Answer:

  • Establishments of monetary reserve fund :
  • The fund has played a major role in achieving the sizeable stock of the national currencies of different countries.
  • Monetary discipline and cooperation:
  • To achieve this objective, it has provided assistance only to those countries which make sincere efforts to solve their problems.
  • Special interest in the problems of UDCs.
  • The fund has provided financial assistance to solve the balance of payment problem of UDCs.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 3.
Explain the objectives of WTO?
Answer:

  1. To ensure the reduction of tariffs and other barriers.
  2. To eliminate discrimination in trade.
  3. To facilitate a higher standard of living.
  4. To facilitate optimal use of the world’s resources.
  5. To enable the LDCs to secure a fair share in the growth of international trade.
  6. To ensure linkages between trade policies, environmental policies, and sustainable development.

Question 4.
What are the achievements of WTO?
Answer:

  1. The use of restrictive measures for BOP problems has declined markedly.
  2. Services trade has been brought into the multilateral system and many countries, as in goods are opening their markets for trade and investment.
  3. The trade policy review mechanism has created a process of continuous monitoring of trade policy developments.

Question 5.
Explain the functions of WTO?
Answer:
The following are the functions of the WTO:

  • It facilitates the implementation, administration, and operation of the objectives of the Agreement and of the Multilateral Trade Agreements.
  • It provides the forum for negotiations among its members, concerning their multilateral trade relations in matters relating to the agreements.
  • It administers the Understanding of Rules and Procedures governing the Settlement of Disputes.
  • It cooperates with the IMF and the World Bank and its affiliated agencies with a view to achieving greater coherence in global economic policymaking.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Question 6.
Explain the achievements of BRICs.

  • The establishment of the Contingent Reserve Arrangement (CRA) has further deepened and consolidated the partnership of its members in the economic-financial area.
  • A New Development Bank was established with headquarters at Shangai, China in 2015.
  • BRIC countries are in a leading position in setting the global agenda and have great influence in global governance.

XI. 5 Mark Questions
Question 1.
Explain the functions of IMF.
Answer:
1. Bringing stability to the exchange rate:

  • The IMF is maintaining exchange rate stability.
  • Emphasizes devaluation criteria.
  • Restricting members to go in for multiple exchange fates.

2. Correcting BOP disequilibrium:
IMF helps in correcting short period disequilibrium in-the balance of payments of its member countries.

3. Determining par values:

  • IMF enforces the system of determination of par value of the currencies of the member countries.
  • IMF ensures smooth working of the international monetary system in favour of some developing countries.

4. Balancing demand and supply of currencies:
The Fund can declare a currency as scarce currency which is in great demand and can increase its supply by borrowing it from the country concerned or by purchasing the same currency in exchange for gold.

5. Reducing trade restrictions:
The Fund also aims at reducing tariffs and other trade barriers imposed by the member countries with the purpose of removing restrictions on remit¬tance of funds or to avoid discriminating practices.

6. Providing credit facilities:
IMF is providing credit facilities which include basic credit facility, extended fund facility for a period of three years, compensatory financing facility, and structural adjustment facility.

Samacheer Kalvi 12th Economics Guide Chapter 8 International Economic Organisations

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Tamilnadu State Board New Syllabus Samacheer Kalvi 12th Computer Science Guide Pdf Chapter 4 Algorithmic Strategies Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

12th Computer Science Guide Algorithmic Strategies Text Book Questions and Answers

I. Choose the best answer (1 Mark)

Question 1.
The word comes from the name of a Persian mathematician Abu Ja’far Mohammed ibn-i Musa al Khwarizmi is called?
a) Flowchart
b) Flow
c) Algorithm
d) Syntax
Answer:
c) Algorithm

Question 2.
From the following sorting algorithms which algorithm needs the minimum number of swaps?
a) Bubble sort
b) Quick sort
c) Merge sort
d) Selection sort
Answer:
d) Selection sort

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 3.
Two main measures for the efficiency of an algorithm are
a) Processor and memory
b) Complexity and capacity
c) Time and space
d) Data and space
Answer:
c) Time and space

Question 4.
The complexity of linear search algorithm is
a) O(n)
b) O(log n)
c) O(n2)
d) O(n log n)
Answer:
a) O(n)

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 5.
From the following sorting algorithms which has the lowest worst-case complexity?
a) Bubble sort
b) Quick sort
c) Merge sort
d) Selection sort
Answer:
c) Merge sort

Question 6.
Which of the following is not a stable sorting algorithm?
a) Insertion sort
b) Selection sort
c) Bubble sort
d) Merge sort
Answer:
b) Selection sort

Question 7.
Time Complexity of bubble sort in best case is
a) θ (n)
b) θ (nlogn)
c) θ (n2)
d) θ n(logn)2)
Answer:
a) θ (n)

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 8.
The Θ notation in asymptotic evaluation represents
a) Base case
b) Average case
c) Worst case
d) NULL case
Answer:
b) Average case

Question 9.
If a problem can be broken into sub problems which are reused several times, the problem possesses which property?
a) Overlapping sub problems
b) Optimal substructure
c) Memoization
d) Greedy
Answer:
a) Overlapping sub problems

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 10.
In dynamic programming, the technique of storing the previously calculated values is called ?
a) Saving value property
b) Storing value property
c) Memoization
d) Mapping
Answer:
c) Memoization

II. Answer the following questions (2 Marks)

Question 1.
What is an Algorithm?
Answer:
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. An algorithm can be implemented in any suitable programming language.

Question 2.
Define Pseudocode
Answer:

  • Pseudocode is a notation similar to programming languages.
  • Pseudocode is a mix of programming-language-like constructs and plain English.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 3.
Who is an Algorist?
Answer:
A person skilled in the design of algorithms is called Agorist.

Question 4.
What is Sorting?
Answer:
Sorting is a method of arranging a group of items in ascending or descending order. Various sorting techniques in algorithms are Bubble Sort, Quick Sort, Heap Sort, Selection Sort, Insertion Sort.

Question 5.
What is searching? Write its types.
Answer:

  1. Searching is a process of finding a particular element present in given set of elements.
  2. Some of the searching types are:

Linear Search
Binary Search.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

III. Answer the following questions (3 Marks)

Question 1.
List the characteristics of an algorithm
Answer:
Input, Output, Finiteness, Definiteness, Effectiveness, Correctness, Simplicity, Unambiguous, Feasibility, Portable and Independent.

Question 2.
Discuss Algorithmic complexity and its types
Answer:

  • 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.
  • Time Complexity: The Time complexity of an algorithm is given by the number of steps taken by the algorithm to complete the process.
  • Space Complexity: Space complexity of an algorithm is the amount of memory required to run to its completion.

The space required by an algorithm is equal to the sum of the following two components:

  • A fixed part is defined as the total space required to store certain data and variables for an algorithm.
  • Example: simple variables and constants used in an algorithm.
  • A variable part is defined as the total space required by variables, which sizes depends on the problem and its iteration.
  • Example: recursion used to calculate factorial of a given value n.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 3.
What are the factors that influence time and space complexity?
Answer:
Time Complexity:
The Time complexity of an algorithm is given by the number of steps taken by the algorithm to complete the process.

Space Complexity:
Space complexity of an algorithm is the amount of memory required to run to its completion. The space required by an algorithm is equal to the sum of the following two components:

A fixed part is defined as the total space required to store certain data and variables for an algorithm. For example, simple variables and constants used in an algorithm. A variable part is defined as the total space required by variables, which sizes depends on the problem and its iteration. For example, recursion used to calculate the factorial of a given value n.

Question 4.
Write a note on Asymptotic notation
Answer:

  • Asymptotic Notations are languages that use meaningful statements about time and space complexity.
  • The following three asymptotic notations are mostly used to represent time complexity of algorithms:

Big O:
Big O is often used to describe the worst -case of an algorithm.

Big Ω:

  • Big O mega is the reverse Big O if Bi O is used to describe the upper bound (worst – case) of an asymptotic function,
  • Big O mega is used to describe the lower bound (best-case).

Big Θ:
When an algorithm has complexity with lower bound = upper bound, say that an algorithm has a complexity 0 (n log n) and Ω (n log n), it actually has the complexity Θ (n log n), which means the running time of that algorithm always falls in n log n in the best-case and worst-case.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 5.
What do you understand by Dynamic programming?
Answer:
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. The dynamic programming approach is similar to divide and conquer. The given problem is divided into smaller and yet smaller possible subproblems.

IV. Answer the following questions (5 Marks)

Question 1.
Explain the characteristics of an algorithm.
Answer:

Input Zero or more quantities to be supplied.
Output At least one quantity is produced.
Finiteness Algorithms must terminate after a finite number of steps.
Definiteness all operations should be well defined. For example, operations involving division by zero or taking square root for negative numbers are unacceptable.
Effectiveness Every instruction must be carried out effectively.
Correctness The algorithms should be error-free.
Simplicity Easy to implement.
Unambiguous The algorithm should be clear and unambiguous. Each of its steps and their inputs/outputs should be clear and must lead to only one meaning.
Feasibility Should be feasible with the available resources.
Portable An algorithm should be generic, independent of any programming language or an operating system able to handle all range of inputs.
Independent An algorithm should have step-by-step directions, which should be independent of any programming code.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 2.
Discuss Linear search algorithm
Answer:

  • Linear search also called sequential search is a sequential method for finding a particular value in a list.
  • This method checks the search element with each element in sequence until the desired element is found or the list is exhausted. In this searching algorithm, list need not be ordered.

Pseudocode:

  • Traverse the array using for loop
  • In every iteration, compare the target search key value with the current value of the list.
  • If the values match, display the current index and value of the array.
  • If the values do not match, move on to the next array element.
  • If no match is found, display the search element not found.

Example:

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies 1

  • To search the number 25 in the array given below, a linear search will go step by step in a sequential order starting from the first element in the given array if the search element is found that index is returned otherwise the search is continued till the last index of the array.
  • In this example number 25 is found at index number 3.

Question 3.
What is Binary search? Discuss with example
Answer:
Binary Search:

  • Binary search also called a half-interval search algorithm.
  • It finds the position of a search element within a sorted array.
  • The binary search algorithm can be done as a dividend- and -conquer search algorithm and executes in logarithmic time.

Example:

  • List of elements in an array must be sorted first for Binary search. The following example describes the step by step operation of binary search.
  • Consider the following array of elements, the array is being sorted so it enables to do the binary search algorithm.
    Let us assume that the search element is 60 and we need to search the location or index of search element 60 using binary search.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies 2

  • First ‘we find index of middle element of the array by using this formula:
    mid = low + (high – low)/2
  • Here it is, 0+(9 – 0)/2 = 4 (fractional part ignored)v So, 4 is the mid value of the array.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies 3

  • Now compare the search element with the value stored at mid-value location 4. The value stored at location or index 4 is 50, which is not match with search element. As the search value 60 is greater than 50.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies 4

  • Now we change our low to mid + land find the new mid-value again using the formula.
    low to mid + 1
    mid = low + (high -low) / 2
  • Our new mid is 7 now. We compare the value stored at location 7 with our target value 31.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies 5

  • The value stored at location or index 7 is not a match with search element, rather it is more than what we are looking for. So, the search element must be in the lower part from the current mid-value location

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies 6

  • The search element still not found. Hence, we calculated the mid again by using the formula.
    high = mid – 1
    mid = low + (high – low)/2
    Now the mid-value is 5.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies 7

  • Now we compare the value stored at location 5 with our search element. We found that it is a match.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies 8

  • We can conclude that the search element 60 is found at the location or index 5.
  • For example, if we take the search element as 95, For this value this binary search algorithm returns the unsuccessful result.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 4.
Explain the Bubble sort algorithm with example
Answer:
Bubble sort:

  • Bubble sort algorithm simple sorting algorithm.
  • The algorithm starts at the beginning of the I list of values stored in an array.
  • It compares each pair of adjacent elements and swaps them if they are in the unsorted order.
  • This comparison and passed to be continued until no swaps are needed, which indicates that the list of values stored in an array is sorted.
  • The algorithm is a comparison sort, is named for the way smaller elements “bubble” to the top of the list.
  • Although the algorithm is simple, it is too slow and less efficient when compared to insertion sort and other sorting methods.
  • Assume list is an array of n elements. The swap function swaps the values of the given array elements.

Pseudocode:

  • Start with the first element i.e., index = 0, compare the current element with the next element of the array.
  • If the current element is greater than the next element of the array, swap them.
    If the current element is less than the next or right side of the element, move to the next element. Go to Step 1 and repeat until the end of the index is reached.

Let’s consider an array with values {15, 11, 16, 12, 14, 13} Below, we have a pictorial representation of how bubble sort will sort the given array.
Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies 9
The above pictorial example is for iteration-d. Similarly, remaining iteration can be done. The final iteration will give the sorted array. At the end of all the iterations we will get the sorted values in an array as given below:
Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies 10

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 5.
Explain the concept of dynamic programming with a suitable example.
Answer:
Dynamic programming:
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. The dynamic programming approach is similar to divide and conquer. The given problem is divided into smaller and yet smaller possible subproblems.

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. Dynamic programming approaches are used to find the solution in an optimized way. For every inner subproblem, the dynamic algorithm will try to check the results of the previously solved sub-problems. The solutions of overlapped subproblems are combined in order to get a better solution.

Steps to do Dynamic programming:

  1. The given problem will be divided into smaller overlapping sub-problems.
  2. An optimum solution for the given problem can be achieved by using the result of a smaller sub-problem.
  3. Dynamic algorithms use Memoization.

Fibonacci Series – An example:
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 1 can be taken as 0 and 1.
Fibonacci series satisfies the following conditions:
Fibn = Fibn-1 + Fibn-2
Hence, a Fibonacci series for the n value 8 can look like this
Fib8 = 0 1 1 2 3 5 8 13

Fibonacci Iterative Algorithm with Dynamic programming approach:
The following example shows a simple Dynamic programming approach for the generation of the Fibonacci series.
Initialize f0 = 0, f1 = 1
step – 1: Print the initial values of Fibonacci f0 and f1
step – 2: Calculate fibanocci fib ← f0 + f1
step – 3: Assign f0 ← f1, f1 ← 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
For 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 1 3 2 1 3 4 5 5

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

12th Computer Science Guide Algorithmic Strategies Additional Questions and Answers

Choose the best answer: (1 Marks)

Question 1.
Which one of the following is not a data structure?
(a) Array
(b) Structures
(c) List, tuples
(d) Database
Answer:
(d) Database

Question 2.
Linear search is also called
a) Quick search
b) Sequential search
c) Binary search
d) Selection search
Answer:
b) Sequential search

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 3.
Which is a wrong fact about the algorithm?
(a) It should be feasible
(b) Easy to implement
(c) It should be independent of any programming languages
(d) It should be generic
Answer:
(c) It should be independent of any programming languages

Question 4.
Which search algorithm can be done as divide and- conquer search algorithm?
a) linear
b) Binary search
c) Sequential
d) Bubble
Answer:
b ) Binary search

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 5.
Which of the following sorting algorithm is too slow and less efficient?
a) Selection
b) Bubble
c) Quick
d) Merge
Answer:
b) Bubble

Question 6.
Which of the following programming is used whenever problems can be divided into similar sub-problems?
a) Object-oriented
b) Dynamic
c) Modular
d) Procedural
Answer:
b) Dynamic

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 7.
Which of the following is the reverse of Big O?
a) Big μμ
b) Big Ω
c) Big symbol
d) Big ΩΩ
Answer:
b) Big Ω

Question 8.
How many different phases are there in the analysis of algorithms and performance evaluations?
(a) 1
(b) 2
(c) 3
(d) Many
Answer:
(b) 2

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 9.
Which of the following is a finite set of instructions to accomplish a particular task?
a) Flowchart
b) Algorithm
c) Functions
d) Abstraction
Answer:
b) Algorithm

Question 10.
The way of defining an algorithm is called
a) Pseudo strategy
b) Programmatic strategy
c) Data structured strategy
d) Algorithmic strategy
Answer:
d) Algorithmic strategy

Question 11.
Time is measured by counting the number of key operations like comparisons in the sorting algorithm. This is called as ……………………………
(a) Space Factor
(b) Key Factor
(c) Priori Factor
(d) Time Factor
Answer:
(d) Time Factor

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 12.
Efficiency of an algorithm decided by
a) Definiteness, portability
b) Time, Space
c) Priori, Postriori
d) Input/output
Answer:
b) Time, Space

Question 13.
Which of the following should be written for the selected programming language with specific syntax?
a) Algorithm
b) Pseudocode
c) Program
d) Process
Answer: c) Program

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 14.
How many components required to find the space required by an algorithm?
a) 4
b) 3
c) 2
d) 6
Answer:
c) 2

Question 15.
Which of the following component is defined as the total space required to store certain data and variables for an algorithm?
a) Time part
b) Variable part
c) Memory part
d) Fixed part
Answer:
d) Fixed part

Question 16.
Which is true related to the efficiency of an algorithm?
(I) Less time, more storage space
(II) More time, very little space
(a) I is correct
(b) II is correct
(c) Both are correct
(d) Both are wrong
Answer:
(c) Both are correct

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 17.
Time and Space complexity could be considered for an
a) Algorithmic strategy
b) Algorithmic analysis
c) Algorithmic efficiency
d) Algorithmic solution
Answer:
c) Algorithmic efficiency

Question 18.
Which one of the following is not an Asymptotic notation?
(a) Big
(b) Big \(\Theta\)
(c) Big Ω
(d) Big ⊗
Answer:
(d) Big ⊗

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 19.
How many asymptotic notations are mostly used to represent time complexity of algorithms?
a) Two
b) Three
c) One
d) Many
Answer:
b) Three

II. Answer the following questions (2 and 3 Marks)

Question 1.
Define fixed part in the space complexity?
Answer:
A fixed part is defined as the total space required to store certain data and variables for an algorithm. For example, simple variables and constants used in an algorithm.

Question 2.
Write a pseudo code for linear search
Answer:

  • Traverse the array using ‘for loop’
  • In every iteration, compare the target search key value with the current value of the list.
  • If the values match, display the current index and value of the array
  • If the values do not match, move on to the next array element
  • If no match is found, display the search element not found.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 3.
Design an algorithm to find the square of the given number and display the result?
Answer:
Problem: Design an algorithm to find the square of the given number and display the result. 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 ← x* x
  • Step 4 – display the resulting square
  • Step 5 – stop

The algorithm could be designed to get a solution of a given problem. A problem can be solved in many ways. Among many algorithms, the optimistic one can be taken for implementation.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 4.
Write a pseudo code for bubble sort
Answer:

  • Start with the first element i.e., index = 0, compare the current element with the next element of the array.
  • If the current element is greater than the next element of the array, swap them.
  • If the current element is less than the next or right side of the element, move to the next element.
  • Go to Step 1 and repeat until end of the index is reached.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 5.
Write a pseudo code for selection sort.
Answer:

  • Start from the first element i.e., index= 0, we search the smallest element in the array, and replace it with the element in the first position.
  • Now we move on to the second element position, and look for smallest element present in the sub-array, from starting index to till the last index of sub-array.
  • Now replace the second smallest identified in step-2 at the second position in the or original array, or also called first position in the sub-array.

Question 6.
Write a note on Big omega asymptotic notation
Answer:

  • Big Omega is the reverse Big 0, if Big 0 is used to describe the upper bound (worst – case) of a asymptotic function,
  • Big Omega is used to describe the lower bound (best-case).

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 7.
Name the factors where the program execution time depends on?
The program execution time depends on:

  1. Speed of the machine
  2. Compiler and other system Software tools
  3. Operating System
  4. Programming language used
  5. The volume of data required

Question 8.
Write a note on memoization.
Answer:
Memoization or memoisation is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again.

Question 9.
Give examples of data structures.
Answer:
Examples for data structures are arrays, structures, list, tuples, dictionary.

Question 10.
Define- Algorithmic Strategy?
Answer:
The way of defining an algorithm is called Algorithmic Strategy.

Question 11.
Define algorithmic solution?
Answer:
An algorithm that yields expected output for a valid input is called an algorithmic solution

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 12.
Define- Algorithm Analysis?
Answer:
An estimation of the time and space complexities of an algorithm for varying input sizes is called Algorithm Analysis.

Question 13.
What are the different phases in the analysis of algorithms and performance?
Answer:
Analysis of algorithms and performance evaluation can be divided into two different phases:
A Priori estimates: This is a theoretical performance analysis of an algorithm. Efficiency of an algorithm is measured by assuming the external factors.
Posteriori testing: This is called performance measurement. In this analysis, actual statistics like running time and required for the algorithm executions are collected.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

Question 14.
Define the Best algorithm?
Answer:
The best algorithm to solve a given problem is one that requires less space in memory and takes less time to execute its instructions to generate output.

Question 15.
Write a note Asymptotic Notations?
Answer:
Asymptotic Notations are languages that uses meaningful statements about time and space complexity.

Samacheer Kalvi 12th Computer Science Guide Chapter 4 Algorithmic Strategies

III. Answer the following questions (5 Marks)

Question 1.
Differentiate Algorithm and program
Answer:

Algorithm

Program

1 An algorithm helps to solve a given problem logically and it can be contrasted with the program Program is an expression of algorithm in a programming language.
2 The algorithm can be categorized based on its implementation methods, design techniques, etc The algorithm can be implemented by a structured or object-oriented programming approach
3 There is no specific rules for algorithm writing but some guidelines should be followed. The program should be written for the selected language with specific syntax
4 The algorithm resembles a pseudo-code that can be implemented in any language Program is more specific to a programming language

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.3

Tamilnadu State Board New Syllabus Samacheer Kalvi 12th Business Maths Guide Pdf Chapter 5 Numerical Methods Ex 5.3 Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 12th Business Maths Solutions Chapter 5 Numerical Methods Ex 5.3

Choose the most suitable answer from the given four alternatives:

Question 1.
Δ²y0 =
(a) y2 – 2y1 + y0
(b) y2 + 2y1 – y0
(c) y2 + 2y1 + y0
(d) y2 + y1 + 2y0
Solution:
(a) y2 – 2y1 + y0
Hint:
Δ²y0 = (E – 1)²y0
= (E² – 2E + 1) y0
= E²y0 – 2Ey0 + y0
= y2 – 2y1 + y0

Question 2.
Δf(x) =
(a) f (x + h)
(b) f (x) – f (x + h)
(c) f (x + h) – f(x)
(d) f(x) – f (x – h)
Solution:
(c) f (x + h) – f(x)
Hint:
Δf(x) = f (x + h) – f(x)

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.3

Question 3.
E≡
(a) 1 + Δ
(b) 1 – Δ
(c) 1 + ∇
(d) 1 – ∇
Solution:
(a) 1 + Δ

Question 4.
If h = 1, then Δ(x²) =
(a) 2x
(b) 2x – 1
(c) 2x + 1
(d) 1
Solution:
(c) 2x + 1
Hint:
Δ(x²) = (x + h)² – (x)²
= x² + 2xh + h² – x²
Δ(x²) = 2xh + h²
If h = 1 Δ (x²) = 2x + 1

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.3

Question 5.
If c is a constant then Δc =
(a) c
(b) Δ
(c) Δ²
(d) 0
Solution:
(d) 0

Question 6.
If m and n are positive integers then Δm Δn f(x)=
(a) Δm+n f(x)
(b) Δm f(x)
(c) Δn f(x)
(d) Δm-n f(x)
Solution:
(a) Δm+n f(x)

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.3

Question 7.
If ‘n’ is a positive integer Δn-n f(x)]
(a) f(2x)
(b) f(x + h)
(c) f(x)
(d) Δf(x)
Solution:
(c) f(x)
Hint:
Δn-n f(x)] = Δn-n f(x) = Δ0 f(x)
= f(x)

Question 8.
E f(x) =
(a) f(x – h)
(b) f(x)
(c) f(x + h)
(d) f(x + 2h)
Solution:
(c) f (x + h)

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.3

Question 9.
∇≡
(a) 1 + E
(b) 1 – E
(c) 1 – E-1
(d) 1 + E-1
Solution:
(c) 1 – E-1

Question 10.
∇ f(a) =
(a) f(a) + f(a – h)
(b) f(a) – f(a + h)
(c) f(a) – f(a – h)
(d) f(a)
Solution:
(c) f(a) – f(a- h)

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.3

Question 11.
For the given points (x0, y0) and (x1, y1) the Lagrange’s formula is
(a) y(x) = \(\frac { x-x_1 }{x_0-x_1}\) y0 + \(\frac { x-x_0 }{x_1-x_0}\) y1
(b) y(x) = \(\frac { x_1-x}{x_0-x_1}\) y0 + \(\frac { x-x_0 }{x_1-x_0}\) y1
(c) y(x) = \(\frac { x-x_1 }{x_0-x_1}\) y0 + \(\frac { x-x_0 }{x_1-x_0}\) y0
(d) y(x) = \(\frac { x_1-x }{x_0-x_1}\) y0 + \(\frac { x-x_0 }{x_1-x_0}\) y0
Solution:
(a) y(x) = \(\frac { x-x_1 }{x_0-x_1}\) y0 + \(\frac { x-x_0 }{x_1-x_0}\) y1

Question 12.
Lagrange’s interpolation formula can be used for
(a) equal intervals only
(b) unequal intervals only
(c) both equal and unequal intervals
(d) none of these.
Solution:
(c) both equal and unequal intervals.

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.3

Question 13.
If f(x) = x² + 2x + 2 and the interval of differencing is unity then Δf(x)
(a) 2x – 3
(b) 2x + 3
(c) x + 3
(d) x – 3
Solution:
(b) 2x + 3
Hint:
Given:
f(x) = x² + 2x + 2
Δf(x) = f (x + h) – f (x)
since h = 1
Δf(x) = f (x – 1) – f (x)
= [(x + 1)² + 2(x + 1) + 2] – [x² + 2x + 2]
= [x² + 2x + 1 + 2x + 2 + 2] – [x² + 2x + 2]
= x² + 4x + 5 – x² – 2x – 2
= 2x + 3

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.3

Question 14.
For the given data find the value of Δ³y0 is
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.3 1
(a) 1
(b) 0
(c) 2
(d) -1
Solution:
(b) 0
Hint:
From this data
y0 = 12; y1 = 13; y2 = 15; y3 = 18
Δ³y0 = (E – 1)³ y0
= (E³ – 3E² + 3E – 1) y0
= E³y0 – 3E²y0 + 3Ey0 – y0
= y3 – 3y2 + 3y1 – y0
= 18 – 3 (15) + 3 (13) – 12
= 18 – 45 + 39 – 12
= 57 – 57 = 0

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.3

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2

Tamilnadu State Board New Syllabus Samacheer Kalvi 12th Business Maths Guide Pdf Chapter 5 Numerical Methods Ex 5.2 Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 12th Business Maths Solutions Chapter 5 Numerical Methods Ex 5.2

Question 1.
Using graphic method, find the value of y when x = 48 from the following data:
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 1
Solution:
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 2
The value of y when x = 48 is 6.8

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2

Question 2.
The following data relates to indirect labour expenses and the level of output
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 3
Estimate the expenses at a level of output of 350 units, by using graphic method.
Solution:
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 4

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2

Question 3.
Using Newton’s forward interpolation formula find the cubic polynomial.
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 5
Solution:
Since we use the Newton’s forward interpolation formula.
y(x= x0+nh) = y0 + \(\frac { n }{1!}\) Δy0 + \(\frac { n(n-1) }{2!}\) Δ²y0 + \(\frac { n(n-1)(n-2) }{3!}\) Δ³y0 + ………
To find y at x
∴ x0 + nh = x
0 + n(1) = x
∴ n = x
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 6
= 1 + x + (x² – x) (-1) + 2x (x² – 3x + 2)
y = 1 + x – x² + x + 2x³ – 6x² + 4x
y = 2x³ – 7x² + 6x + 1
∴ f(x) = 2x³ – 7x² + 6x + 1

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2

Question 4.
The population of a city in a censes taken once in 10 years is given below. Estimate the population in the year 1955.
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 7
Solution:
Let the year be x and population be y. To find the population for the year 1955.
(ie) The value of y at x = 1955
Since the value of y is required near the beginning of the table, we use the Newton’s forward interpolation formula.
y(x= x0+nh) = y0 + \(\frac { n }{1!}\) Δy0 + \(\frac { n(n-1) }{2!}\) Δ²y0 + \(\frac { n(n-1)(n-2) }{3!}\) Δ³y0 + ………
To find y at x = 1955
∴ x0 + nh = 1955; x0 = 1951, h = 10
⇒ 1951 + n(10) = 1955
10n = 1955 – 1951 ⇒ 10n = 4
n = \(\frac { 4 }{10}\) = 0.4
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 8
y = 35 + 2.8 – 1.08 + 0.064
= 37.864 – 1.08
y = 36.784
∴ Population in the year 1955 is 36.784 (lakhs)

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2

Question 5.
In an examination the number of candidates who secured marks between certain interval were as follows:
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 9
Estimate the number of candidates whose marks are lessthan 70.
Solution:
Since the required mark is at the end of the table, we apply Backward interpolation formula. Let the marks be x and No. of candidates be y.
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 10
To find y at x = 70
x = x0 + nh ⇒ 70 = 100 + n(20)
70 – 100 = 20n
20n = -30 ⇒ n = \(\frac { -30 }{20}\)
n = -1.5
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 11
= 235 – 25.5 – 12.375 – 1.125
= 235 – 39
= 196
∴ 196 candidates secured less than 70 marks

Question 6.
Find the value of f(x) when x = 32 from the following table
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 12
Solution:
Since the value of f(x) is required near the beginning of the table, we use the Newton’s forward interpolation formula.
y(x= x0+nh) = y0 + \(\frac { n }{1!}\) Δy0 + \(\frac { n(n-1) }{2!}\) Δ²y0 + \(\frac { n(n-1)(n-2) }{3!}\) Δ³y0 + ………
To find y at x = 32
∴ x0 + nh = 32;
30 + n(5) = 32
5n = 32 – 30 ⇒ 5n = 2
n = \(\frac { 2 }{5}\)
∴ n = 0.4
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 13
= 15.9 – 0.4 – 0.024 – 0.0128 – 0.00832
15.9 – 0.44512 = 15.45488
= 15.45
∴ when x = 32, f(x) = 15.45

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2

Question 7.
The following data gives the melting point of a alloy of lead and zinc where ‘t’ is the temperature in degree c and p is the percentage of lead in the alloy
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 14
Find the melting point of the alloy containing 84 percent lead.
Solution:
Since the required value is at the end of the table, apply backward interpolation formula. To find T at p = 84
T(p= p0+nh) = Tn + \(\frac { n }{1!}\) ∇Tn + \(\frac { n(n+1) }{2!}\) ∇²T0 + \(\frac { n(n+1)(n+2) }{3!}\) Δ³T0 + ………
To find T at P = 84
Pn + nh = 84
90 + n(10) = 84
10n = 84 – 90
10n = -6 ⇒ n = \(\frac { -6 }{10}\)
n = -0.6
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 15
= 304 – 16.8 – 0.24 – 0.091392
= 304 – 17.131392
= 286.86
Hence the melting point of the alloy is 286.86° c.

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2

Question 8.
Find f(2.8) from the following
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 16
Solution:
Since the required value is at the end of the table, apply backward interpolation formula.
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 17
To find y at x = 2.8
∴ x0 + nh = 2.8
∴ 3 + n(1) = 2.8
n = 2.8 – 3
n = -0.2
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 18
= 34 – 4.6 – 1.12 – 0.288
= 34 – 6.008
= 27.992
∴ f(2.8) = 27.992

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2

Question 9.
Using interpolation estimate the output of a factory in 1986 from the following data
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 19
Solution:
Here the intervals are unequal. By Lagrange’s in-terpolation formula we have,
x0 = 1974, x1 = 1978, x2 = 1982, x3 = 1990
y0 = 25, y1 = 60, y2 = 80, y3 = 170, and x = 1986.
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 20
∴ output in 1986 is 108.75 (thousand tones)

Question 10.
Use lagrange’s formula and estimate from the following data the number of workers getting income not exceeding Rs. 26 per month.
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 21
Solution:
Here the intervals are unequal. By Lagrange’s In-terpolation formula we have,
x0 = 15, x1 = 25, x2 = 30, x3 = 35
y0 = 36, y1 = 40, y2 = 45, y3 = 48 and x = 26.
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 22
∴ Required No.of workers = 42 Persons (approximately)

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2

Question 11.
Using interpolation estimate the business done in 1985 from the following data
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 23
Solution:
Here the intervals are unequal. By Lagrange’s formula we have,
x0 = 1982, x1 = 1983, x2 = 1984, x3 = 1986
y0 = 150, y1 = 235, y2 = 365, y3 = 525 and x = 1985.
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 24
∴ Business done in the year 1985 is 481.25 lakhs.

Question 12.
Using interpolation, find the value of f(x) when x = 15
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 25
Solution:
Here the intervals are unequal, By Lagrange’s in-terpolation formula we have,
x0 = 3, x1 = 7, x2 = 11, x3 = 19
y0 = 42, y1 = 43, y2 = 47, y3 = 60 and x = 15.
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2 26

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.2

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Tamilnadu State Board New Syllabus Samacheer Kalvi 12th Computer Science Guide Pdf Chapter 13 Python and CSV Files Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 12th Computer Science Solutions Chapter 13 Python and CSV Files

12th Computer Science Guide Python and CSV Files Text Book Questions and Answers

I. Choose the best answer (1 Mark)

Question 1.
A CSV file is also known as a…………………… (March 2020)
a) Flat File
b) 3D File
c) String File
d) Random File
Answer:
a) Flat File

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 2.
The expansion of CRLF is
a) Control Return and Line Feed
b) Carriage Return and Form Feed
c) Control Router and Line Feed
d) Carriage Return and Line Feed
Answer:
d) Carriage Return and Line Feed

Question 3.
Which of the following module is provided by Python to do several operations on the CSV files?
a) py
b) xls
c) csv
d) os
Answer:
c) csv

Question 4.
Which of the following mode is used when dealing with non-text files like image or exe files?
a) Text mode
b) Binary mode
c) xls mode
d) csv mode
Answer:
b) Binary mode

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 5.
The command used to skip a row in a CSV file is
a) next()
b) skip()
c) omit()
d) bounce()
Answer:
a) next()

Question 6.
Which of the following is a string used to terminate lines produced by writer()method of csv module?
a) Line Terminator
b) Enter key
c) Form feed
d) Data Terminator
Answer:
a) Line Terminator

Question 7.
What is the output of the following program?
import csv
d=csv.reader(open(‘c:\PYPRG\chl3\city.csv’))
next (d)
for row in d:
print(row)
if the file called “city.csv” contain the following details
chennai,mylapore
mumbai,andheri
a) chennai,mylapore
b) mumbai,andheri
c) chennai,mumbai
d) chennai,mylapore
Answer:
b) mumbai,andheri

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 8.
Which of the following creates an object which maps data to a dictionary?
a) listreader()
b) reader()
c) tuplereader()
d) DicReader ()
Answer:
d) DicReader ()

Question 9.
Making some changes in the data of the existing file or adding more data is called
a) Editing
b) Appending
c) Modification
d) Alteration
Answer:
c) Modification

Question 10.
What will be written inside the file test, csv using the following program
import csv
D = [[‘Exam’],[‘Quarterly’],[‘Halfyearly’]]
csv.register_dialect(‘M’,lineterminator = ‘\n’)
with open(‘c:\pyprg\chl3\line2.csv’, ‘w’) as f:
wr = csv.writer(f,dialect=’M’)
wr.writerows(D)
f.close()
a) Exam Quarterly Halfyearly
b) Exam Quarterly Halfyearly
c) EQH
d) Exam, Quarterly, Halfyearly
Answer:
d) Exam, Quarterly, Halfyearly

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

II. Answer the following questions (2 Marks)

Question 1.
What is CSV File?
Answer:
A CSV file is a human-readable text file where each line has a number of fields , separated by commas or some other delimiter. A CSV file is also known as a Flat File. Files in the CSV format can be imported to and exported from programs that store data in tables, such as Microsoft Excel or OpenOfficeCalc.

Question 2.
Mention the two ways to read a CSV file using Python.
Answer:
There are two ways to read a CSV file.

  1. Use the CSV module’s reader function
  2. Use the DictReader class.

Question 3.
Mention the default modes of the File.
Answer:
The default is reading in text mode. In this mode, while reading from the file the data would be in the format of strings.
The default mode of csv file in reading and writing is text mode.

Mode Description
Y Open a file for reading, (default)
Y Open in text mode, (default)

Question 4.
What is the use of next() function?
Answer:
#using operator module for sorting multiple columns
sortedlist = sorted (data, key=operator.itemgetter(1))

Question 5.
How will you sort more than one column from a csv file? Give an example statement.
Answer:
To sort by more than one column you can use itemgetter with multiple indices.
operator.itemgetter (1,2)
Syntax:
sortedlist = sorted( data, key=operator. itemgetter( Colnumber ),reverse=True)
Example:
data = csv.reader(open(‘c:\\ PYPRG\\sample8.csv’))
next(data) #(to omit the header)
#using operator module for sorting multiple columns
sortedlist = sorted (data, key=operator. itemgetter(1,2))

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

III. Answer the following questions (3 Marks)

Question 1.
Write a note on open() function of python. What is the difference between the two methods?
Answer:
Python has a built-in function open() to open a file. This function returns a file object, also called a handle, as it is used to read or modify the file accordingly.
For Example
>>> f = openf’sample.txt”) bopen file in current directory andf is file object
>>> f = open(‘c:\ \pyprg\ \chl3sample5.csv’) #specifyingfull path
You can specify the mode while opening a file. In mode, you can specify whether you want to read ‘r’, write ‘w’ or append ‘a’ to the file, you can also specify “text or binary” in which the file is to be opened.
The default is reading in text mode. In this mode, while reading from the file the data would be in the format of strings.
On the other hand, binary mode returns bytes and this is the mode to be used when dealing with non-text files like image or exe files.
f = open(“test.txt”) # since no mode is specified the default mode it is used
#perform file operations
f.close( )
The above method is not entirely safe. If an exception occurs when you are performing some operation with the file, the code exits without closing the file. The best way to do this is using the “with” statement. This ensures that the file is closed when the block inside with is exited. You need not to explicitly call the close() method. It is done internally.

Question 2.
Write a Python program to modify an existing file.
Answer:
Coding:
import csv ,
row = [‘3: ‘Meena’Bangalore’]
with opent’student.csv; ‘r’) as readFile:
reader = csv.reader(readFile)
lines = list(reader) # list()- to store each
row of data as a list
lines [3] = row
with open (student.csv, ‘w’) as writeFile:
# returns the writer object which converts the user data with delimiter
writer = csv.writer(writeFile)
#writerows()method writes multiple rows to a csv file
writer, writerows(lines)
readFile.close()
writeFile. close()

Original File:

Roll No Name

City

1 Harshini, Chennai
2 Adhith, Mumbai
3 Dhuruv Bangalore
4 egiste, Tirchy
5 Venkat Madurai

Modified File after the coding:

Roll No Name

City

1 Harshini, Chennai
2 Adhith, Mumbai
3 Meena Bangalore
4 egiste, Tirchy
5 Venkat Madurai

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 3.
Write a Python program to read a CSV file with default delimiter comma (,).
Answer:
Coding:
#importing csv
import csv
#opening the csv file which is in different location with read mode with opent(‘c.\\pyprg\\samplel-csv’, ‘r’) as F:
#other way to open the file is f= (‘c:\ \ pyprg\ \ samplel.csv’, ‘r’)
reader = csv.reader(F)
# printing each line of the Data row by row
print(row)
F.close()
Output:
[‘SNO’, ‘NAME’, ‘CITY’]
[‘12101’, ‘RAM’, ‘CHENNAI’]
[‘12102′,’LAV ANYA’,’TIRCHY’]
[‘12103’, ‘LAKSHMAN’, ‘MADURAI’]

Question 4.
What is the difference between the write mode and append mode?
Answer:

write mode append mode
The write mode creates a new file. append mode is used to add the data at the end of the file if the file already exists .
If the file is already existing write mode overwrites it. Otherwise creates a new one.

Question 5.
What is the difference between reader() and DictReader() function?
Answer:

reader() DictReader() function
csv. reader and csv.writer work with list/ tuple csv.DictReader and csv.DictWriter work with dictionary.
csv. reader and csv.writer do not take additional argument. csv.DictReader and csv.DictWriter take additional argument fieldnames that are used as dictionary keys

IV. Answer the following questions (5 Marks)

Question 1.
Differentiate Excel file and CSV file.
Answer:

Excel \ csv : /                     ‘
Excel is a binary file that holds information about all the worksheets in a file, including both content and formatting CSV format is a plain text format with a series of values separated by commas.
XLS files can only be read by applications that have been specially written to read their format, and can only be written in the same way. CSV can be opened with any text editor in Windows like notepad, MS Excel, Open Office, etc.
Excel is a spreadsheet that saves files into its own proprietary format viz. xls or xlsx CSV is a format for saving tabular information into a delimited text file with extension .csv
Excel consumes-more memory while importing data Importing CSV files can be much faster, and it also consumes less memory

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 2.
Tabulate the different mode with its meaning.
Answer:

Mode Description
V open a file for reading (default)
‘W’ Open a file for writing. Creates a new file if it does not exist or truncates the file if it exists.
‘x’ Open a file for exclusive creation. If the file already exists, the operation fails.
‘a’ Open for appending at the end of the file without truncating it. Creates a new file if it does not exist.
‘t’ Open in text mode, default
‘b’ Open in binary mode.
‘+’ Open a file for updating (reading and Writing)

Question 3.
Write the different methods to read a File in Python.
Answer:
There are two ways to read a CSV file.

  1. Use the csv module’s reader function
  2. Use the DictReader class.

csv module’s reader function:

  • We can read the contents of CSV file with the help of csv.reader() method.
  • The reader function is designed to take each line of the file and make a list of all columns.
  • Using this method one can read data from csv files of different formats like quotes (” “), pipe (|) and comma (,).

Syntax for csv.reader(): .
csv.reader( fileobject,delimiter,fmtparams)
where

  • file object: passes the path and the mode of the file
  • delimiter: an optional parameter containing the standard dilects like , | etc can be omitted. .
  • Fmtparams: optional parameter which help to override the default values of the dialects like skipinitialspace,quoting etc. can be omitted.

Program:
#importing csv
import csv
#opening the csv file which is in different
location with read mode
with opent(‘c.\ \pvprg\ \samplel-csv’, ‘r’) as F:
#other way to open the file is f= (‘c:\ \
pyprg\ \ samplel.csv’, ‘r’)
reader = csv.reader(F)
#printing each line of the Data row by row
print(row)
F.close()
Output:
[‘SNO’, ‘NAME’, ‘CITY’]
[‘12101’, ‘RAM’, ‘CHENNAI’]
[‘12102’, ‘LAVANYA’, ‘TIRCHY’]
[‘12103’, ‘LAKSHMAN’, ‘MADURAI’]

Reading CSV File into A Dictionary:

  • To read a CSV file into a dictionary can be done by using DictReader class of csv module which works similar to the reader() class but creates an object which maps data to a dictionary.
  • The keys are given by the field names as parameters.
  • DictReader works by reading the first line of the CSV and using each comma-separated value in this line as a dictionary key.
  • The columns in each subsequent row then behave like dictionary values and can be accessed with the appropriate key (i.e. fieldname).

Program:
import csv
filename = ‘c:\\pyprg\ \sample8.csv’
inputfile =csv.DictReader( opet(filename’r’))
for row in inputfile:
print(dict(row)) #dict() to print data
Output:
{‘ItemName’: ‘Keyboard ” ‘Quantity’: ’48’}
{‘ItemName ‘: ‘Monitor: ‘Quantity’: ’52’}
{‘ItemName ‘: ‘Mouse ” ‘Quantity’: ’20’}

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 4.
Write a Python program to write a CSV File with custom quotes.
Answer:
Coding:
import csv
csvData = [[‘SNO’,’Items’], [‘l’/Pen’],
[‘2′,’Book’], [‘3′,’Pencil’]]
csv.register_dialect (‘myDialect’, delimiter = ‘ | ‘,quotechar = quoting = csv. QUOTE_ALL)
with open(‘c:\\pyprg\\ch13\\ quote. csv’, ‘w’) as csvFile:
writer = csv.writer(csvFile, dialect=’myDialect’)
writer. writerows(csvData)
print (“writing completed”)
csvFile.close()

When you open the “quote.csv” file in notepad, We get following output:

Sl.No “Items”
1 “Pen”
2 “Book”
3 “Pencil”

Question 5.
Write the rules to be followed to format the data in a CSV file.
Answer:
1. Each record (row of data) is to be located on a separate line, delimited by a line break by pressing enter key.
Example:
xxx.yyy↵(↵denotes enter Key to be pressed)

2. The last record in the file mayor may not have an ending line break.
Example:
ppp,qqq↵
yyy,xxx

3. 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.
Example:
field_name 1,field_name2,field_name3
zzz,yyy,xxx CRLF(Carriage Return and Line Feed)

4. 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.
Example:
Red, Blue

5. 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
Example.
“Red”,”Blue”,”Green”↵      #Field data with” ‘
Black,White,Yellow   #Field data without double quotes

6. Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes.
Example:
Red, Blue, Green

7. If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be preceded with another double quote.
Example:
“Red,” “Blue”, “Green”

12th Computer Science Guide Python and CSV Files Additional Questions and Answers

I. Choose the best answer (1 Marks)

Question 1.
CSV means ……………………… files
(a) common server values
(b) comma-separated values
(c) correct separator values
(d) constructor separated value
Answer:
(b) comma-separated values

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 2.
Abbreviation of CSV
a) Condition systematic values
b) Column separated values
c) Comma solution values
d) Comma-separated values
Answer:
d) Comma-separated values

Question 3.
csv files cannot be opened with ………………………..
(a) notepad
(b) MS Excel
(c) open office
(d) HTML
Answer:
(d) HTML

Question 4.
Which of the following can protect if the data itself contains commas in a CSV file?
a) ”
b) ,,
c) ” ”
d) ‘
Answer:
c) ” ”

Question 5.
In a CSV file, each record is to be located on a separate line, delimited by a line break by pressing
a) Enter key
b) ESV key
c) Tab key
d) Shift key
Answer:
a) Enter key

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 6.
Find the wrong statement.
(a) csv files can be opened with any text editor
(b) Excel files can be opened with any text editor
Answer:
(b) Excel files can be opened with any text editor

Question 7.
…………………… built-in function is used to open a file in Python.
a) readfn ()
b) open ()
c) reader ()
d) openfile ()
Answer:
b) open ()

Question 8.
…………… mode can be used when CSV files dealing with non-text files.
a) Write mode
b) Binary mode
c) Octal mode
d) Write mode
Answer:
b) Binary mode

Question 9.
The default file open mode is ……………….
a) rt
b) x
c) a
d) rw
Answer:
a) rt

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 10.
Any field containing a newline as part of its data should be given in ……………………..
(a) quotes
(b) double-colon
(c) colon
(d) double quotes
Answer:
(d) double quotes

Question 11.
…………………..function is designed to take each line of the file and make a list of all columns?
a) read ()
b) reader ()
c) row ()
d) list ()
Answer:
b) reader ()

Question 12.
…………………. describes the format of the CSV file that is to be read.
a) line space
b) dialect
c) whitespace
d) delimiter
Answer:
b) dialect

Question 13.
Find the correct statement
(I) The last record in the file may or may not have an ending line break
(II) Header is a must with the same format as record lines.
(a) (I) is true, (II) is False
(b) (I) is False, (II) – True
(c) (I), (II) – both are true
(d) (I), (II) – both are false
Answer:
(a) (I) is true, (II) is False

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 14.
……………. is used to add elements in CSV.
a) update ()
b) write ()
c) append ()
d) addition ()
Answer:
c) append ()

Question 15.
In CSV file,………………… function is used to sort more than one column.
a) sorter ()
b) multiplesort ()
c) itemsort ()
d) morecolumns ()
Answer:
a) sorter ()

Question 16.
In open command, file name can be represented in ………………………
(a) ” ”
(b) ”
(c) $
(d) both a & b
Answer:
(d) both a & b

Question 17.
………………… method writes a row of data into the specified CSV file.
a) rows ()
b) writerow ()
c) row_data ()
d) row_write ()
Answer:
b) writerow ()

Question 18.
……………. Action is used to print the data in dictionary form; t without order.
a) diet ()
b) dictionarys ()
c) read_dict ()
d) print_dict ()
Answer:
a) diet ()

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 19.
…………………method will free up the resources that were tied with the file.
a) freeup ()
b) open_res ()
c) resource_close ()
d) close ()]
Answer:
d) close ()]

Question 20.
In-text mode, while reading from the file the data would be in the format of ……………………..
(a) int
(b) float
(c) char
(d) strings
Answer:
(d) strings

Question 21.
CSV files are saved with extension
a) .CV
b) .CSV
c) .CVSC
d) .CSE
Ans :
b) .CSV

Question 22.
……………. command arranges a CSV file list value in descending order
a) listname.sort ()
b) listname.ascd ()
c) list_name. sort(reverse))
d) sorting ()
Answer:
c) list_name. sort(reverse))

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 23.
A ……………….. is a string used to terminate lines produced by the writer.
a) Linefeed
b) Delimiters
c) Line Terminator
d) SingleQuotes
Ans:
c) Line Terminator

Question 24.
Which format is not allowed to read data from cav files?
(a) quotes
(b) pipe
(c) comma
(d) Asterisk
Answer:
(d) Asterisk

II. Answer the following questions (2 and 3 Marks)

Question 1.
Compare text mode and binary mode.
Answer:

Text mode Binary mode
The default is reading in text mode. Binary mode returns bytes.
In this mode, while reading from the file the data would be in the format of strings. This is the mode to be used when dealing with non-text files like image or exe files

Question 2.
What is the syntax for csv.reader( )?
Answer:
The syntax for csv.reader( ) is
where csv.reader(fileobject,delimiter,fmtparams)
file object – passes the path and the mode of the file
delimiter – an optional parameter containing the standard dialects like etc can be omitted.
fmtparams – optional parameter which helps to override the default values of the dialects like skipinitialspace, quoting etc. Can be omitted.

Question 3.
What is the use of the CSV file?
Answer:

  • CSV is a simple file format used to store tabular data, such as a spreadsheet or database.
  • Since they’re plain text, they’re easier to import into a spreadsheet or another storage database, regardless of the specific software

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 4.
Define: Garbage collector
Answer:
Python has a garbage collector to clean up unreferenced objects but, the user must not rely on it to close the file.

Question 5.
How to read from CSV file that contains space at the beginning using register dialect() method?
Answer:

  • The whitespaces can be removed, by registering new dialects using csregister, dialect () class of csv module.
  • A dialect describes the format of the csv file that is to be r 4, In dialects the parameter “skipinitialspace” is used for removing whitespaces after the delimiter.

Question 6.
Define dialect.
Answer:

  • A dialect is a class of csv module which helps to define parameters for reading and writing CSV.
  • It allows to create, store, and re-use of various formatting parameters for data.

Question 7.
Compare: sort() and sorted ().
Answer:

  • The sorted () method sorts the elements of a given item in a specific order – ascending or descending.
  • sort () method performs the same way as sorted ().
  • Only difference, sort ( ) method doesn’t return any value and changes the original list
    itself. ‘

Question 8.
Explain How to read CSV file into a dictionary?
Answer:

  • To read a CSV file into a dictionary can be done by using DictReader class of csv module which works similar to the reader ( )class but creates an object which maps data to a dictionary.
  • The keys are given by the fieldnames as parameter.

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 9.
What are the different formats to create csv files?
Answer:

  1. CSV file – data with default delimiter comma (,)
  2. CSV file – data with Space at the beginning
  3. CSV file – data with quotes
  4. CSV file – data with custom Delimiters

Question 10.
Give the differences between writerow() and writerows() method.
Answer:

writerow() writerows()
The writerow() method writes one row at a time. writerows() method writes all the data at once to the new CSV file.
The writerow() method writes one-dimensional data. The writerows() method writes multi-dimensional data.

Question 11.
Define: Modification
Answer:
Making some changes in the data of the existing file or adding more data is called a modification.

Question 12.
Write a note on Line Terminator.
Answer:

  • A-Line Terminator is a string used to terminate lines produced by the writer.
  • The default value is \r or \n. We can write a csv file with a line terminator in Python by registering new dialects using csv. register_dialect () class of csv module.

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 13.
Explain How to write Dictionary into CSV file with custom dialects?
Answer:
Coding:
import csv
csv.registecdialect(‘myDialect’, delimiter = ‘I; quoting=csv.QUOTE_ALL)
with open(‘c:\\pyprg\\chl3\\ vgrade.
csv, ‘w’) as csvfile
fieldnames = [‘Name’, ‘Grade’]
writer = csv. Diet Writer (csvfile, fieldnames = fieldnames, dialect =”myDialect”)
writer.writeheader()
writer.writerows([{‘Grade’: ‘B’, ‘Name’: Anu’},
{‘Gra dee:’ ‘nA/ ‘Name’: ‘Beena,’}
{Grade’: ‘C: ‘Name’: ‘Tarun’}])
print(“writing completed”)

“Name” “Grade”
“Anu” “B”
“Beena” “A”
“Tarun” “C”

Question 14.
How will you create CSV in text editor?
Answer:

  • To create a CSV file in Notepad, First open a new file using
    File → New or Ctrl +N
  • Then enter the data separating each value with a comma and each row with a new line.
  • Example: consider the following details
    Topic1, Topic2, Topic3
    one, two, three
    Example1, Example2, Example3
  • Save this content in a file with the extension.csv.

Question 15.
Explain how to create a new normal CSV file to store data
Answer:

  • The csv.writer() method returns a writer object which converts the user’s data into delimited strings on the given file-like object.
  • The writerow() method writes a row of data into the specified file.
  • The syntax for csv.writer() is csv. writer(fileobject,delimiter,fmtparams)
    where,
Fileobject: passes the path and the mode of the file.
Delimiter: an optional parameter containing the standard dilects like , | etc can be omitted.
Fmtparams: optional parameter which help to override the default values of the dialects like skipinitialspace, quoting etc. can be omitted.

Coding:
import csv
csvData = [[‘Student’, ‘Age’], [‘Dhanush’, ’17’], [‘Kalyani’, ’18’], [‘Ram’, ’15’]]
with open(‘c:\ \ pyprg\ \chl3\ \ Pupil.csv’, ‘w’) as CF:
writer = csv.writer(CF)
# CF is the file object
writer.writerows(csvData)
# csvData is the List name
CF.close()

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 16.
Explain how to write CSV Files With Quotes
Answer:
We can write the csv file with quotes, by registering new dialects using
csv.register_dialect() class of csv module.

Coding:
import csv
info = [[‘SNO’, ‘Person’, ‘DOB’],
[‘1′,’Madhu’, ’18/12/2001′],
[‘2’, ‘Sowmya’,’19/2/1998′],
[‘3’, ‘Sangeetha’,’20/3/1999′],
[‘4’, ‘Eshwar’, ’21/4/2000′],
[‘5’, ‘Anand’, ’22/5/2001′]]
csv.register_
dialect(‘myDialect’,quoting=csv.QUOTE_ALL)
with open(‘c:\ \ pyprg\ \ chl3\ \ person, csv’, ‘w’) as f:
writer = csv.writer(f, dialect=’myDialect,)
for row in info:
writer.writerow(row)
f.close()

When you open “person.csv” file, we get following output:
” SNO”,” Person” /’DOB”
“l”,”Madhu”,”18/12/2001″
“2”,”So wmya”,”19/2/1998″
” 3″,” Sangeetha” ,”20/ 3/1999″
“4”/’Eshwar”/’21/4/2000″
“5”/’Anand”,”22/5/2001″

III. Answer the following questions (5 Marks)

Question 1.
Explain how to read a specific column in a CSV file.
Answer:
Coding for printing the selected column:
import csv
#opening the csv file which is in different location with read mode f=open(“c:\\pyprg\\13ample5.csv”/r/) #reading the File with the help of csv. reader()
readFile=csv.reader(f)
#printing the selected column
for col in readFile:
print col[0],col[3]
f.close ()

Sample5.csv File in Excel

A B C D
item Name Cost-Rs Quantity Profit
Keyboard 480 12 1152
Monitor 5200 10 10400
Mouse 200 50 2000

OUTPUT

item Name Profit
Keyboard 1152
Monitor 10400
Mouse 2000

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 2.
Explain how to read the CSV file and store it in a list.
Answer:
Coding for reading the CSV file and store it in a list:
import csv
# other way of declaring the filename
inFile= ‘c:\\pyprg\\sample.csv’
F=open (inFile/ r’)
reader = csv.reader(F)
# declaring array
array Value = [ ]
# displaying the content of the list for row
in reader:
arr ay Value. append (row)
print(row)
F.close()
OUTPUT:
[‘Topic1’, ‘Topic2’, ‘Topic3’]
[‘ one’, ‘two’, ‘three’]
[‘Example!.’, ‘Example2’, ‘Example3’]

Question 3.
Explain how to read the CSV file and sort the data in a particular column.
Answer:
Coding for reading the CSV file and sort the data in a particular column:
# sort a selected column given by user
leaving the header column
import csv
# other way of declaring the filename
inFile= ‘c:\\pyprg\\sample6.csv’
# opening the csv file which is in the same location of this
python file
F=open(inFile:r’)
# reading the File with the help of csv. readerO
reader = csv.reader(F)
# skipping the first row(heading)
next(reader)
# declaring a list
array Value = [ ]
a = int(input (“Enter the column number 1 to 3:-“))
# sorting a particular column-cost
for row in reader:
arrayValue.append(row[ a])
array Value, sort ()
for row in arrayValue:
print (row)
Eclose ()
OUTPUT:
Enter the column number 1 to 3:- 2
50
12
10

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 4.
Explain how to read CSV file with a line Terminator.
Answer:
Coding:
import csv
Data = [[‘Fruit’, ‘Quantity’], [Apple, ‘5’],
[Banana, ‘7’]’ [‘Mango: ‘8’]]
csv.register_dialect(‘myfrialect; delimiter = ‘ |’, lineterminator = ‘\n’)
with open(‘ c: \ \ py pr g\ \ ch3\ \ line .csv: ‘w’) as f:
writer = csv.writer(f, dialect=’myDialect’)
writer.writerows(Data)
f.close ()
Output:

Fruit Quantity
Apple 5
Banana 7
Mango 8

Samacheer Kalvi 12th Computer Science Guide Chapter 13 Python and CSV Files

Question 5.
Write a program to set data at runtime and writing it in a CSV file.
Answer:
Coding:
import csv
with open (‘c\\pyprg\\ch13\\
vdynamicfile.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\ \ chl3\ \ dynamicfile. csv”,r’)
reader=csv.reader (F)
for row in reader:
print (row)
F.close()
OUTPUT:
Name?: Nivethitha
Date of birth: 12/12/2001
Place: Chennai
Do you want to enter more y/n?: y
Name?: Leena
Date of birth: 15/10/2001
Place: Nagercoil
Do you want to enter more y/n?: y
Name?: Padma
Date of birth: 18/08/2001
Place: Kumbakonam
Do you want to enter more y/n?: n
[‘Nivethitha’, ’12/12/2001′, ‘Chennai’]
[]
[‘Leena’, ’15/10/2001′, ‘Nagercoil’]
[]
[‘Padma’, ’18/08/2001′, ‘Kumbakonam’]

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Tamilnadu State Board New Syllabus  Samacheer Kalvi 12th Economics Guide Pdf Chapter 7 International Economics Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 12th Economics Solutions Chapter 7 International Economics

12th Economics Guide International Economics Text Book Back Questions and Answers

PART- A

Multiple Choice questions

Question 1.
Trade between two countries is known as ………………… trade.
a) External
b) Internal
c) Inter-regional
d) Home
Answer:
a) External

Question 2.
Which of the following factors influence trade?
a) The stage of development of a product.
b) The relative price of factors of productions.
c) Government
d) All of the above
Answer:
d) All of the above

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 3.
International trade differs from domestic trade because of
a) Trade restrictions
b) Immobility of factors
c) Different government polices
d) All the Above
Answer:
d) All the Above

Question 4.
In general, a primary reason why nations conduct international trade is because
a) Some nations prefer to produce one thing while others produce another
b) Resources are not equally distributed among all trading nations
c) Trade enhances opportunities to accumulate profits
d) Interest rates are not identical in all trading nations
Answer:
b) Resources are not equally distributed among all trading nations

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 5.
Which of the following is a modern theory of international trade?
a) Absolute cost
b) Comparative cost
c) Factor endowment theory
d) none of these
Answer:
c) Factor endowment theory

Question 6.
Exchange rates are determined in
a) Money Market
b) foreign exchange market
c) Stock Markét
d) Capital Market
Answer:
b) foreign exchange market

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 7.
Exchange rate for currencies is determined by supply and demand under the system of
a) Fixed exchange rate
b) Flexible exchange rate .
c) Constant
d) Government regulated
Answer:
b) Flexible exchange rate .

Question 8.
‘Net export equals ………………..
a) Export x Import
b) Export + Import
c) Export – Import
d) Exports of services only
Answer:
c) Export – Import

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 9.
Who among the following enunciated the concept of single factoral terms of trade? .
a) Jacob Viner
b) G.S.Donens
c) Taussig
d) J.S.Mill
Answer:
a) Jacob Viner

Question 10.
Terms of Trade of a country show …………..
a) Ratio of goods exported and imported
b) Ratio of import duties
c) Ratio of prices of exports and imports
d) Both (a) and (c)
Answer:
c) Ratio of prices of exports and imports

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 11.
Favirnrable trade means value of exports are ………………… than that of imports.
a) More
b) Less
c) More or Less
d) Not more than
Answer:
a) More

Question 12.
If there is an imbalance in the trade balance (more imports than exports), it can be reduced by ……………….
a) Decreasing customs duties
b) Increasing export duties
c) Stimulating exports
d) Stimulating imports
Answer:
c) Stimulating exports

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 13.
BOP includes . :
a) Visible items only
b) invisible items only
c) both visible and invisible items
d) merchandise trade only
Answer:
c) both visible and invisible items

Question 14.
Components of balance of payments of a country includes
a) Current account
b) Official account
c) Capital account
d) All of above
Answer:
d) All of above

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 15.
In the case of BOT,
a) Transactions of goods are recorded.
b) Transactions of both goods and services’ are recorded
c) Both capital and financiál accounts are included
d) All of these
Answer:
a) Transactions of goods are recorded.

Question 16.
Tourism and travel are classified in which of balance of payments accounts?
a) merchandise trade account
b) services account
c) unilateral transfers account
d) capital account
Answer:
b) services account

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 17.
Cyclical disequlibrium in BOP occurs because of
a) Different paths of business cycle.
b) The income elasticity of demand or price elasticity of demand is different.
c) long – run changes in an economy
d) Both (a) and (b).
Answer:
d) Both (a) and (b).

Question 18.
Which of the following is not an example of foreign direct investment?
a) The construction of a new auto assembly plant overseas
b) The acquisition of an existing steel mill overseas
c) The purchase of bonds or stock issued by a textile company overseas
d)The creation of a wholly owned business firm overseas
Answer:
c) The purchase of bonds or stock issued by a textile company overseas

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 19.
Foreign direct investments not permitted in India
a) Banking
b) Automatic energy
c) Pharmaceutical
d) Insurance
Answer:
b) Automatic energy

Question 20.
Benefits of FDI include, theoretically
a) Boost in Economic Growth
b) Increase in the import and export of goods and services
c) Increased employment and skill levels
d) All of these
Answer:
d) All of these

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

PART – B

Answer the following questions.
Each question carries 2 marks.

Question 21.
What is International Economics?
Answer:

  1. International Economics is that branch of economics which is concerned with the exchange of goods and services between two or more countries. Hence the subject matter is mainly related to foreign trade.
  2. International Economics is a specialized field of economics which deals with the economic interdependence among countries and studies the effects of such interdependence and the factors that affect it.

Question 22.
Define international trade.
Answer:
It refers to the trade or exchange of goods and services between two or more countries.

Question 23.
State any two merits of trade.
Answer:

  1. Trade is one of the powerful forces of economic integration.
  2. The term ‘trade’ means the exchange of goods, wares or merchandise among people.

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 24.
What is the main difference between Adam Smith and Ricardo with regard to the emergence of foreign trade?
Answer:
According to Adam Smith, the basis of international trade was absolute cost advantage whereas Ricardo demonstrates the comparative cost Advantage.

Question 25.
Define terms of Trade.
Answer:
Terms of Trade:

  1. The gains from international trade depend upon the terms of trade which refers to the ratio of export prices to import prices.
  2. It is the rate at which the goods of one country are exchanged for goods of another country’.
  3. It is expressed as the relation between export prices and import prices.
  4. Terms of trade improve when average price of exports is higher than the average price of imports.

Question 26.
What do you mean by balance of payments?
Answer:
BOP is a systematic record of a country’s economic and financial transactions with the rest of the world over a period of time.

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 27.
What is meant by Exchange Rate?
Answer:
Meaning of Foreign Exchange (FOREX):

1. FOREX refers to foreign currencies. The mechanism through which payments are effected between two countries having different currency systems is called the FOREX system. It covers methods of payment, rules and regulations of payment and the institutions facilitating such payments.

2. “FOREX is the system or process of converting one national currency into another, and of transferring money from one country to another”.

PART -C

Answer the following questions.
Each question carries 3 marks.

Question 28.
Describe the subject matter of International Economics.
Answer:

  1. Pure Theory of Trade:
    This component includes the causes for foreign trade, and the determination of the terms of trade and exchange rates.
  2. Policy Issues:
    Under this part policy issues regarding international trade are covered.
  3. International Cartels and Trade Blocs:
    This part deals with the economic integration in the form of international cartels, trade blocs and also the operation of MNCs.
  4. International Financial and Trade Regulatory Institutions:
    The financial institutions which influence international economic transactions and relations shall also be the part of international economics.

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 29.
Compare the Classical Theory of international trade with the Modern Theory of International trade.
Answer:

Classical Theory of International Trade

Modern Theory of Internationa] Trade

1. This theory explains the phenomenon of international trade on the basis of labour theory of value. This theory explains the phenomenon of international trade on the basis of general theory of value.
2. It Presents a one factor model. It presents a multi factor model.
3. It attributes the difference in the comparative costs to differences in the productive efficiency of workers in the two countries. It attributes the differences in comparative costs to the differences in factor endowment in the two countries.

Question 30.
Explain the Net Barter Terms of Trade and Gross Barter Terms of Trade.
Answer:
Net Barter Terms of Trade and Gross Barter Terms of Trade was developed by Taussig in 1927.
Net Barter Terms of Trade: .
It is the ratio between the prices of exports and of imports is called the ” net bar-ter terms of trade”.
It is expressed as
Tn = (Px/Pm) x 100
Tn- Net Barter Terms of Trade
Px – Index number of export Prices
Pm – Index number of import prices .
Gross barter terms of trade:
It is an index of relationship between total physical quantity of imports and the total physical quantity of exports.
Tg = (Qm/ Qx) x 100
Qm – Index of import quantities
Qx – Index of export quantities

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 31.
Distinguish between Balance of Trade and Balance of Payments.
Answer:
Balance of Trade and Balance of payments are two different concepts in the sub-ject of International trade.

Balance of Trade

Balance of Payments

 1.Balance of Trade refers to the total value of a country’s exports of commodities and total value of imports of commodities.  1. Balance of payments is a systematic record of a country’s economic and financial transactions with the rest of the world over a period of time.
2. There are two types of BOT, they are favourable balance of Trade and unfavourable balance of Trade. 2. There are two types of BOP’s they are favourable BOP and unfavorable BOP.

Question 32.
What are import quotas?
Answer:
Import Control: Imports may be controlled by

  1. Imposing or enhancing import duties
  2. Restricting imports through import quotas
  3. Licensing and even prohibiting altogether the import of certain non-essential items. But this would encourage smuggling.

Question 33.
Write a brief note on the flexible exchange rate.
Answer:
Under the flexible exchange rate also known as the floating exchange rate system exchange rates are freely determined in an open market by market forces of demand and supply.

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 34.
State the objectives of Foreign Direct Investment.
Answer:
FDI has the following objectives.

  1. Sales Expansion
  2. Acquisition of resources
  3. Diversification
  4. Minimization of competitive risk

PART – D

Answer the following questions.
Each question carries 5 marks.

Question 35.
Discuss the differences between Internal Trade and International Trade.
Answer:

Internal Trade

International Trade

1. Trade takes place between different individuals and firms within the same nation. Trade takes place between different individuals and firms in different countries.
2. Labour and capital move freely from one region to another. 2. Labour and capital do not move easily from one nation to another.
3.There will be free flow of goods and services since there are no restrictions. 3. Goods and services do not easily move from one country to another since there are a number of restrictions like tariff and quota.
4.There is only one common currency. 4. There are different currencies.
5. The physical and geographical conditions of a country are more or less similar. 5. There are differences in physical and geographical conditions of the two countries.
6.Trade and financial regulations are more or less the same. 6. Trade and financial regulations such as interest rate, trade laws differ between countries.

Question 36.
Explain briefly the Comparative Cost Theory.
Answer:

  • David Ricardo formulated a systematic theory called’ Comparative cost Theory.
    Later it was refined by J.S.Mill, Marshall, Taussig and others.
  • Ricardo demonstrates that the basis of trade is the comparative cost difference.
  • In other words, trade can take place even if the absolute cost difference is absent but there is comparative cost difference.

Assumptions:

  •  There are only two nations and two commodities.
  • Labour is the only element of cost of production.
  • All labourers are of equal efficiency.
  • Labour is perfectly mobile within the country but perfectly immobile between countries.
  • Production is subject to the law of constant returns.
  • Foreign trade is free from all barriers.
  • No change in technology.
  • No transport cost.
  • Perfect Competition.
  • Full employment.
  • No government intervention.
    Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics 1

Country

Cloth Wheat

Domestic Exchange Ratios

America 100 120 1 Wheat = 1.2 cloth
India 90* 80 1 Wheat = 0.88 cloth

Illustration:

  • Ricardo’s theory of comparative cost can be explained with a hypothetical example of production costs of cloth and wheat in America and India.
  • However, India should concentrate on the production of wheat in which she enjoys a comparative cost advantage. \((80 / 120 \leq 90 / 100)\)
  • For America the comparative Cost disadvantage is lesser in cloth production. Hence America will specialize in the production of cloth and export it to India is exchange for wheat.
  • With trade, India can get I unit of cloth and I unit of wheat by using its 160 labour units. Otherwise, India will have to use 170 units of labour, America also gains from this trade.

With trade, America can get 1 unit of cloth and one unit of wheat by using its 200 units of labour. Otherwise, America will have to use 220 units of labour for getting 1 unit of cloth and 1 unit of wheat.

Criticism:

  1. Labour cost is a small portion of the total cost. Hence, theory based on labor cost is unrealistic.
  2. Labourers in different countries are not equal in efficiency.

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 37.
Discuss the Modern Theory of International Trade.
Answer:
Introduction:
The Modern theory of international trade was developed by Swedish economist Eli Heckscher and Bertil Ohlin in 1919.
The Theory:
This model was based on the Ricardian theory of international trade. This theory says that the basis for international trade is the difference in factor endowments. It is otherwise called as ‘Factor Endowment’
This Theory attributes international differences in comparative costs to

  1. The difference in the endowments of factors of production between countries, and
  2. Differences in the factor proportions required in production.

Assumptions:

  •  There are two countries, two commodities and two factors.
  • Countries differ in factor endowments.
  • Commodities are categorized in terms of factor density.
  • Countries use same production technology.
  • Countries have identical demand conditions.
  • There is perfect competition.

Explanation:
According to Heckscher – Ohlin, a capital-abundant country will export capital-intensive goods, while the labour-abundant country will export the labor-intensive goods’.

Illustration:

Particulars

India

America

Supply of Labour 50 24
Supply of Capital 40 30
Capital – Labour Ratio 40/50 = 0.8 30/24 = 1.25

In the above example, even though India has more capital in absolute terms, America is more richly endowed with capital because the ratio of capital in India is 0.8 which is less than that in America where it is 1.25. The following diagram illustrate the pattern of World Trade.
Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics 2
Limitations:

  • Factor endowment of a country may change over time.
  • The efficiency of the same factor may differ in the two countries.

Question 38.
Explain the types of Terms of Trade given by Viner.
Answer:
Terms of Trade related to the Interchange between Productive Resources:

1. The Single Factorial Terms of Trade:
Viner has devised another concept called “the single factor terms of trade” as an improvement upon the commodity terms of trade. It represents the ratio of the export price index to the import-price index adjusted for changes in the productivity of a country’s factors in the production of exports. Symbolically, it can be stated as
Tf = (Px / Pm ) Fx
Where Tf stands for single factorial terms of trade index. Fx stands for productivity in exports (which is measured as the index of cost in terms of quantity of factors of production used per unit of export).

2. Double Factorial Terms of Trade:
Viner constructed another index called “Double factorial terms of Trade”. It is expressed as
Tff = (Px / Pm )(Fx / Fm)
which takes into account the productivity in the country’s exports, as well as the productivity of foreign factors.
Here, Fm represents the import index (which is measured as the index of cost in terms of quantity of factors of production employed per unit of imports).

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 39.
Bring out the components of the balance of payments account.
Answer:
The components of the BOP account of a country are:

  • The current account
  • The capital account
  • The official Reserve assets Account

The Current Account:
It includes all international trade transactions of goods and services, international service transactions, and international unilateral transfers.

The Capital Account:
Financial transactions consisting of direct investment and purchase of interest-bearing financial instruments, non-interest bearing demand deposits and gold fall under the capital account.

The official Reserve Assets Account:
Official reserve transactions consist of movements of international reserves by governments and official agencies to accommodate imbalances arising from the current and capital accounts.
The official reserve assets of a country include its gold stock, holdings of its convertible foreign currencies and Special Drawing Rights and its net position in the International Monetary Fund.

Question 40.
Discuss the various types of disequilibrium in the balance of payments.
Answer:
Types BOP Disequilibrium:
There are three main types of BOP Disequilibrium, which are discussed below.

  1. Cyclical Disequilibrium,
  2. Secular Disequilibrium,
  3. Structural Disequilibrium.

1. Cyclical Disequilibrium:
Cyclical disequilibrium occurs because of two reasons. First, two countries may be passing through different phases of business cycle. Secondly, the elasticities of demand may differ between countries.

2. Secular Disequilibrium:
The secular or long-run disequilibrium in BOP occurs because of long-run and deep-seated changes in an economy as it advances from one stage of growth to another. In the initial stages of development, domestic investment exceeds domestic savings and imports exceed exports, as it happens in India since 1951.

3. Structural Disequilibrium:
Structural changes in the economy may also cause balance of payments disequilibrium. Such structural changes include the development of alternative sources of supply, the development of better substitutes, exhaustion of productive resources or changes in transport routes and costs.

Question 41.
How the Rate of Exchange is determined? Illustrate.
Answer:
The equilibrium rate of exchange is determined in the foreign exchange market in accordance with the general theory of value ie, by the interaction of the forces of demand and supply. Thus, the rate of exchange is determined at the point where demand for forex is equal to the supply of forex.
Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics 3
In the above diagram, Y-axis represents the exchange rate, that is the value of the rupee in terms of dollars. The X-axis represents demand and supply for forex. E is the point of equilibrium where DD intersects SS. The exchange rate is P2.

Question 42.
Explain the relationship between Foreign Direct Investment and economic development.
Answer:

  1. FDI is an important factor in the global economy.
  2. Foreign trade and FDI are closely related. In developing countries like India
  3. FDI in the natural resource sector, including plantations, increases trade volume.
  4. Foreign production by FDI is useful to substitute foreign trade.
  5. FDI is also influenced by the income generated from the trade and regional integration schemes.
  6. FDI is helpful to accelerate the economic growth by facilitating essential imports needed for carrying out development programmes like capital goods, technical know-how, raw materials, and other inputs, and even scarce consumer goods.
  7. FDI may be required to fill the trade gap.
  8. FDI is encouraged by the factors such as foreign exchange shortage, desire to create employment, and acceleration of the pace of economic development.
  9. Many developing countries strongly prefer foreign investment to imports.
  10. However, the real impact of FDI on different sections of an economy.

12th Economics Guide International Economics Additional Important Questions and Answers

One mark

Question 1.
Foreign trade means ………………………..
(a) Trade between nations of the world
(b) Trade among different states
(c) Trade among two states
(d) Trade with one nation
Answer:
(a) Trade between nations of the world

Question 2.
Inter-regional trade is otherwise called as …………………………
a) Domestic trade
b) International trade
c) Internal trade
d) Trade
Answer :
b) International trade

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 3.
‘Principles of Political Economy and Taxation’was published by ……………………
a)J.S.Mill
b) Marshall
c) Taussig
d) E)avid Ricardo
Answer:
d) David Ricardo

Question 4.
The exports of India are broadly classified into ……………………….. categories.
(a) Two
(b) Three
(c) Four
(d) Five
Answer:
(c) Four

Question 5.
Net Barter Terms of Trade was developed by …………………..
a) Torrance
b) Taussig
c) Marshall
d) J. S.tMill
Answer:
b) Taussig

Question 6.
Favourable Balance of payment is expressed as …………..
a) R/P = 1
b) R/P < 1
c) R/P > 1
d)R/P# l
Answer:
c) R/P > 1

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 7.
Flexible Exchange Rate is also called as ……………
a) Nominal Exchange Rate
b) Pegged Exchange Rate
c) Floating Exchange Rate
d) Fixed Exchange Rate
Answer:
c) Floating Exchange Rate

Question 8.
The New Export-Import policy was implemented in ………………………..
(a) 1990 – 1995
(b) 1991 – 1996
(c) 1992 – 1997
(d) 1993 – 1998
Answer:
(c) 1992 – 1997

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 9.
Inflation and exchange rates are ……………….. related
a) Positive
b) directly
c) inversely
d) negatively.
Answer:
c) inversely

Question 10.
FPI is part of capital account of ………………
a) BOT
b) BOP
c) FDI
d) FIT
Answer:
b) BOP

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 11.
……………………….. items means the imports and exports of services and other foreign transfer transactions.
(a) Invisible
(b) Visible
(c) Exports
(d) Imports
Answer:
(a) Invisible

Question 12.
Single Factorial Terms of Trade was devised by …………………
a) Marshall
b) David Ricardo
c) Jacob viner
d) Taussig
Answer:
c) Jacob Viner

II. Match the following

Question 1.
a) Internal trade – 1) Interregional trade
b) International trade – 2) David Ricardo
c) Absolute Cost Advantage – 3) Intraregional trade
d) Comparative cost Advantage – 4) Adam smith
Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics 4
Answer:
c) 3 1 4 2

Question 2.
a) Net Barter Terms of Trade – 1) Tf = (Px / Pm) Fx
b) Gross Barter Terms of Trade – 2) Tf = (Px / Pm) Qx
c) Income Terms of Trade – 3) Tg = (Qm / Qx) x 100
d) Single factoral terms of Trade – 4) Tn = (Px / Pm) x 100

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics 5
Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics 6
Answer:
d) 4 3 2 1

Question 3.
a) Fixed Exchange Rate – 1) NEER
b) Flexible Exchange Rate – 2) REER
c) Nominal Effective Exchange Rate – 3) Pegged exchange rate
d) Real Effective Exchange Rate – 4) Floating exchange rate
Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics 7
Answer:
a) 3 4 12

III. Choose the correct pair

Question 1.
a) Inflation, Exchange Rate – Directly related
b) Interest rate, Exchange Rate – Inversely related
c) Public Debt – reduces inflation
d) Inflation – The exchange rate will be lower
Answer:
d) Inflation – The exchange rate will be lower

Question 2.
a) Foreign Exchange – FOREX
b) Foreign Direct Investment – FII
c) Foreign Portfolio Investment – FDI
d) Foreign Institutional Investment – FPI
Answer:
a) Foreign Exchange – FOREX

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 3.
a) Economic Reforms – 1992
b) Unfavourable BOP – R / P > 1
c) Favourable BOP – R/P<1
d) Devaluation of Indian currency – 29th September 1949
Answer:
d) Devaluation of Indian currency – 29th September 1949

IV. Choose the Incorrect pair

Question 1.
a) Demonstration Effect – Propensity to import
b) Cyclical Disequilibrium – Elasticities of demand remain constant
c) Secular Disequilibrium – Domestic investment exceeds domestic savings
d) Structural Disequilibrium – exhaustion of productive resources.
Answer:
b) Cyclical Disequilibrium – Elastic cities of demand remain constant

Question 2.
a) Absolute cost Advantage – Adam smith
b) Comparative cost Advantage – Ricardo
c) International product life cycle – J.S.Mill
d) Factor Endowment theory – Heckscher and Ohlin
Answer:
c) International product life cycle – J.S.Mill

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

3. a) Net Barter Terms of Trade – Taussig
b) Income Terms of Trade – Taussig
c)The single factorial terms of trade – Viner
b) International product life cycle – Ray Vernon
Answer:
b) Income Terms of Trade – Taussig

V. Choose the correct statement

Question 1.
a) International Economics is concerned with the exchange of goods and services between the people.
b) Absolute cost Advantage theory is based on the assumption of two countries and single commodity.
c) David Ricardo published the book ‘Principles of Political Economy and Taxation’.
d) Heckscher – ohlin theory of international trade is called as classical theory of international trade.
Answer:
c) David Ricardo published the book ‘Principles of Political Economy and Taxation’.

Question 2.
a) The gains from international trade depend upon the terms of trade.
b) Gerald M. Meier classified Terms of trade into four categories.
c) Gross barter terms of trade is named as commodity terms of trade by Viner.
d) The single Factoral Terms of Trade was devised by Taussig.
Answer:
a) The gains from international trade depend upon the terms of trade.

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 3.
a) When receipts exceed payments, the BOP is said to be unfavourable.
b) When receipts are less than payments, the BOP is said to be favourable.
c) The BOP is said to be balanced when the receipts and payments are just equal.
d) Cyclical disequilibrium is caused by structural changes.
Answer:
c) The BOP is said to be balanced when the receipts and payments are just equal.

VI. Choose the incorrect statement:

Question 1.
a) Demonstration effects raise the propensity to import causing adverse balance of payments.
b) A rise in interest rate reduces foreign investment.
c) Devaluation refers to a reduction in the external value of a currency in the terms of other currencies.
d) The mechanism through which payments are effected between two countries having different currency systems is called FOREX system.
Answer:
b) A rise in interest rate reduces foreign investment.

Question 2.
a) FOREX refers to foreign currencies.
b) Exchange rate may be defined as the price paid in the home currency for a unit of foreign currency.
c) The equilibrium exchange rate is that rate, which over a certain period of time, keeps the balance of payments in equilibrium. .
d) Flexible Exchange Rate is also known as pegged exchange rate.
Answer:
d) Flexible Exchange Rate is also known as pegged exchange rate.

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 3.
a) Terms of Trade refers to the ratio of export prices to import prices.
b) International Economics is concerned with the exchange of goods and services between two or more countries.
c) Terms of trade is the rate at which the goods of one country are exchanged for goods of another country.
d) Indian rupee was devalued four times since 1947.
Answer:
d) Indian rupee was devalued four times since 1947

VII. Pick the odd one out:

Question 1.
a) Nomina] Exchange rate
b) Flexible Exchange rate .
c) Real Exchange rate
d) Nominal Effective Exchange rate
Answer:
b) Flexible Exchange rate

Question 2.
a) The major sectors that benefited from FDI in India are:
a) atomic energy
b) Insurance
c) telecommunication
d) Pharmaceuticals.
Answer :
a) atomic energy

VIII. Analyse the Reason:
Question 1.
Assertion (A): Foreign investment mostly takes the form of direct investment,
Reason (R): FDI may help to increase the investment level and thereby the income and employment in the host country.
Answer:
b) Assertion (A) and Reason (R) both are true, but (R) is not the correct explanation of (A).

Question 2.
Assertion (A) : Terms of trade refers to the ratio of export prices to import prices.
Reason (R) : The gains from international trade depend upon the terms of trade.
Answer:
a) Assertion (A) and Reason (R) both are true and (R) is the correct explanation of (A)

Question 3.
Assertion (A) : Trade between countries can take place even if the abso¬ lute cost difference is absent but there is the comparative cost difference.
Reason (R) : A country can gain from trade when it produces at relatively lower costs.
Answer:
b) Assertion (A) and Reason (R) both are true, but (R) is not the correct explanation of (A).
Options:
a) Assertion (A) and Reason (R) both are true and (R) is the correct explanation of (A).
b) Assertion (A) and Reason (R) both are true, but (R) is not the correct explanation of (A).
c) Assertion (A) is true, Reason (R) is false.
d) Both (A) and (R) are false.

IX. 2 Mark Questions

Question 1.
Define “Domestic Trade”?
Answer:

  1. It refers to the exchange of goods and services within the political and geographical boundaries of a nation.
  2. It is a trade within a country.
  3. This is also known as ‘domestic trade’ or ‘home trade’ or ‘intra-regional trade’.

Question 2.
Name the types of trade.
Answer:

  1. Internal Trade
  2. International Trade.

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 3.
What is meant by Internal trade?
Answer:
Internal Trade refers to the exchange of goods and services within the political and geographical boundaries of a nation.

Question 4.
State Adam smith’s theory of Absolute cost Advantage.
Answer:
Adam smith stated that all nations can be benefited when there is free trade and specialisation in terms of their absolute cost advantage.

Question 5.
Write Modern Theory of International Trade Limitations?
Answer:
Limitations:

  1. Factor endowment of a country may change over time.
  2. The efficiency of the same factor (say labour) may differ in the two countries.
  3. For example, America may be labour scarce in terms of number of workers. But in terms of efficiency, the total labour may be larger.

Question 6.
Give note on Income Terms of Trade.
Answer:
Income terms of trade is the net barter terms of trade of a country multiplied by its exports volume index.

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 7.
What is Balance of Trade?
Answer:
Balance of Trade refers to the total value of a country’s exports of commodities and total value of imports of commodities.
8. Give note on Balance of Payments Disequilibrium.
The BOP is said to be balanced when the receipts (R) and Payments (P) are just equal.
R/P = 1

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 8.
Write favourable and unfavourable balance of payments and equations?
Answer:
Favourable BoP: When receipts exceed payments, the BoP is said to be favourable. That is, R / P > 1.
Unfavourable BOP: When receipts are less than payments, the BoP is said to be unfavourable or adverse. That is, R / P < 1.

Question 9.
Define Equilibrium Exchange Rate.
Answer:
The equilibrium exchange rate is that rate, which over a certain period of time, keeps the balance of payments in equilibrium.
X. 3 Mark Questions

Question 1.
What are the factors determining Exchange Rate?
Answer:

  1. Differentials in Inflation
  2. Differentials in Interest Rates
  3. Current Account Deficits
  4. Public Debt
  5. Terms of Trade
  6. Political and Economic stability
  7. Recession
  8. Speculation.

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Question 2.
Write Ricardo’s Theory of Comparative Cost Advantage Assumptions/
Answer:
Assumptions:

  1. There are only two nations and two commodities (2 × 2 models)
  2. Labour is the only element of the cost of production.
  3. All labourers are of equal efficiency.
  4. Labour is perfectly mobile within the country but perfectly immobile between countries.
  5. Production is subject to the law of constant returns.
  6. Foreign trade is free from all barriers.
  7. No change in technology.
  8. No transport cost.
  9. Perfect competition.
  10. Full employment.
  11. No government intervention.

Question 3.
Name the Industrial sectors of India where FDI is not permitted.
Answer:

  • Arms and ammunition
  • Atomic energy
  • Railways
  • Coal and lignite
  • Mining of iron, manganese, chrome, gypsum, sulphur, gold, diamond, copper etc.

XI. 5 Mark Questions

Question 1.
Explain Adam Smith’s Theory of Absolute Cost Advantage.
Answer:
Adam Smith explained the theory of absolute cost advantage in 1776.
Adam Smith argued that all nations can be benefited when there is free trade and specialisation in terms of their absolute cost advantage.

Adam smith’s theory:
According to Adam Smith, the basis of international trade was absolute cost advantage. Trade between two countries would be mutually beneficial when one country produces a commodity at an absolute cost advantage over the other country which in turn produces another commodity at an absolute
cost advantage over the first country.

Assumptions:

  • There are two countries and two commodities
  • Labour is the only factor of production
  • Labour units are homogeneous
  • The cost or price of a commodity is measured by the amount of labour required to produce it.
  • There is no transport cost.

Illustration:
Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics 9
Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics 8
From the illustration, it is clear that India has an absolute advantage in the production of wheat over china and china has an absolute advantage in the production of cloth over India.
Therefore India should specialize in the production of wheat and import cloth from china. China should specialize in the production of cloth and import wheat from India and China.

Question 2.
Briefly explain the Gains from International Trade Categories?
Answer:
Gains from International Trade:

  1. International trade helps a country to export its surplus goods to other countries and secure a better market for it.
  2. Similarly, international trade helps a country to import goods which cannot be produced at all or can be produced at a higher cost.
  3. The gains from international trade may be categorized under four heads.

I. Efficient Production:

  1. International trade enables each participatory country to specialize in the production of goods in which it has absolute or comparative advantages.
  2. International specialization offers the following gains.
    • Better utilization of resources.
    • Concentration in the production of goods in which it has a comparative advantage.
    • Saving in time.
    • Perfection of skills in production.
    • Improvement in the techniques of production.
    • Increased production.
    • Higher standard of living in the trading countries.

II. Equalization of Prices between Countries:
International trade may help to equalize prices in all the trading countries.

  1. Prices of goods are equalized between the countries (However, in reality, it has not happened).
  2. The difference is only with regard to the cost of transportation.
  3. Prices of factors of production are also equalized (However, in reality, it has not happened).

III. Equitable Distribution of Scarce Materials:
International trade may help the trading countries to have equitable distribution of scarce resources.

IV. General Advantages of International Trade:

  1. Availability of a variety of goods for consumption.
  2. Generation of more employment opportunities.
  3. Industrialization of backward nations.
  4. Improvement in the relationship among countries (However, in reality, it has not happened).
  5. Division of labour and specialisation.
  6. Expansion in transport facilities.

Samacheer Kalvi 12th Economics Guide Chapter 7 International Economics

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Tamilnadu State Board New Syllabus Samacheer Kalvi 12th Computer Science Guide Pdf Chapter 14 Importing C++ Programs in Python Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 12th Computer Science Solutions Chapter 14 Importing C++ Programs in Python

12th Computer Science Guide Importing C++ Programs in Python Text Book Questions and Answers

I. Choose the best answer (1 Marks)

Question 1.
Which of the following is not a scripting language?
a) JavaScript
b) PHP
c) Perl
d) HTML
Answer:
d) HTML

Question 2.
Importing C++ program in a Python program is called
a) wrapping
b) Downloading
c) Interconnecting
d) Parsing
Answer:
a) wrapping

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 3.
The expansion of API is
a) Application Programming Interpreter
b) Application Programming Interface
c) Application Performing Interface
d) Application Programming Interlink
Answer:
b) Application Programming Interface

Question 4.
A framework for interfacing Python and C++ is
a) Ctypes
b) SWIG
c) Cython
d) Boost
Answer:
d) Boost

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 5.
Which of the following is a software design technique to split your code into separate parts?
a) Object oriented Programming
b) Modular programming
c) Low Level Programming
d) Procedure oriented Programming
Answer:
b) Modular programming

Question 6.
The module which allows you to interface with the Windows operating system is
a) OS module
b) sys module
c) csv module
d) getopt module
Answer:
a) OS module

Question 7.
getopt() will return an empty array if there is no error in splitting strings to
a) argv variable
b) opt variable
c) args variable
d) ifile variable
Answer:
c) args variable

Question 8.
Identify the function call statement in the following snippet.
if_name_ ==’_main_’:
main(sys.argv[1:])
a) main(sys.argv[1:])
b) _name_
c) _main_
d) argv
Answer:
a) main(sys.argv[1:])

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 9.
Which of the following can be used for processing text, numbers, images, and scientific data?
a) HTML
b) C
c) C++
d) PYTHON
Answer:
d) PYTHON

Question 10.
What does _name_ contains ?
a) C++ filename
b) main() name
c) python filename
d) os module name
Answer:
c) python filename

II. Answer the following questions (2 Marks)

Question 1.
What is the theoretical difference between Scripting language and other programming languages?
Answer:
The theoretical difference between the two is that scripting languages do not require the 228 compilation step and are rather interpreted. For example, normally, a C++ program needs to be compiled before running whereas, a scripting language like JavaScript or Python needs not to be compiled. A scripting language requires an interpreter while a programming language requires a compiler.

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 2.
Differentiate compiler and interpreter.
Answer:
Compiler:

  1. It converts the whole program at a time
  2. It is faster
  3. Error detection is difficult. Eg. C++

Interpreter:

  1. line by line execution of the source code.
  2. It is slow
  3. It is easy Eg. Python

Question 3.
Write the expansion of (i) SWIG (ii) MinGW
Answer:
i) SWIG – Simplified Wrapper Interface Generator
ii) MINGW – Minimalist GNU for Windows

Question 4.
What is the use of modules?
Answer:
We use modules to break down large programs into small manageable and organized files. Furthermore, modules provide reusability of code. We can define our most used functions in a module and import it, instead of copying their definitions into different programs.

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 5.
What is the use of cd command? Give an example.
Answer:

  • cd command is used to change the directory.
  • cd command refers to the change directory and absolute path refers to the coupling path.

Syntax:
cd<absolute path>
Example:
“cd c:\program files\open office 4\program”

III. Answer the following questions (3 Marks)

Question 1.
Differentiate PYTHON and C++
Answer:
PYTHON:

  1. Python is typically an “interpreted” language
  2. Python is a dynamic-typed language
  3. Data type is not required while declaring a variable
  4. It can act both as scripting and general-purpose language

C++:

  1. C++ is typically a “compiled” language
  2. C++ is compiled statically typed language
  3. Data type is required while declaring a variable
  4. It is a general-purpose language

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 2.
What are the applications of a scripting language?
Answer:

  • To automate certain tasks in a program
  • Extracting information from a data set
  • Less code-intensive as compared to traditional programming language
  • Can bring new functions to applications and glue complex systems together

Question 3.
What is MinGW? What is its use?
Answer:
MinGW refers to a set of runtime header files, used in compiling and linking the code of C, C++ and FORTRAN to be run on the Windows Operating System.

MinGw-W64 (a version of MinGW) is the best compiler for C++ on Windows. To compile and execute the C++ program, you need ‘g++’ for Windows. MinGW allows to compile and execute C++ program dynamically through Python program using g++.

Python program that contains the C++ coding can be executed only through the minGW-w64 project run terminal. The run terminal opens the command-line window through which the Python program should be executed.

Question 4.
Identify the modulo operator, definition name for the following welcome.display()
Answer:
Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python 1

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 5.
What is sys.argv? What does it contain?
Answer:
sys.argv is the list of command-line arguments passed to the Python program, argv contains all the items that come along via the command-line input, it’s basically an array holding the command-line arguments of the program.
To use sys.argv, you will first have to import sys. The first argument, sys.argv[0], is always the name of the program as it was invoked, and sys.argv[l] is the first argument you pass to the program (here it is the C++ file).
For example:
main(sys.args[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[l] contains the name of the C++ file which is to be processed.

IV. Answer the following questions (5 Marks)

Question 1.
Write any five features of Python.
Answer:

  • Python uses Automatic Garbage Collection
  • Python is a dynamically typed language.
  • Python runs through an interpreter.
  • Python code tends to be 5 to 10 times shorter than that written in C++.
  • In Python, there is no need to declare types explicitly
  • In Python, a function may accept an argument of any type, and return multiple values without any kind of declaration beforehand.

Question 2.
Explain each word of the following command.
Python < filename.py > – < i >< C++ filename without cpp extension >
Answer:
Python < filename.py > -i < C++ filename without cpp extension >

Python Keyword to execute the Python program from command-line
filename.py Name of the Python program to execute
– i input mode
C++ filename without CPP extension Name of C++ file to be compiled and executed

Example: Python pycpp.py -i pali

Question 3.
What is the purpose of sys, os, getopt module in Python. Explain
Answer:
Python’s sys module:
This module provides access to some variables used by the interpreter and to functions that interact strongly with the interpreter.

Python’s OS module:

  • The OS module in Python provides a way of using operating system dependent functionality.
  • The functions that the OS module allows you to interface with the Windows operating system where Python is running on.

Python getopt module:

  • The getopt module of Python helps us to parse (split) command-line options and arguments.
  • This module provides two functions to enable command-line argument parsing.

Question 4.
Write the syntax for getopt( ) and explain its arguments and return values
Answer:
Syntax of getopt():
, =getopt.
getopt(argv,options, [long options])
where

i) argv:
This is the argument list of values to be parsed (splited). In our program the complete command will be passed as a list.

ii) options:
This is string of option letters that the Python program recognize as, for input or for output, with options (like or ‘o’) that followed by a colon (r), Here colon is used to denote the mode.

iii) long_options :
This parameter is passed with a list of strings. Argument of Long options should be followed by an equal sign C=’). In our program the C++ file name will be passed as string and ‘I’ also will be passed along with to indicate it as the input file.

  • getopt( ) method returns value consisting of two elements.
  • Each of these values are stored separately in two different list (arrays) opts and args.
  • opts contains list of splitted strings like mode, path.
  • args contains any string if at all not splitted because of wrong path or mode.
  • args will be an empty array if there is no error in splitting strings by getopt().

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Example:
opts, args = getopt. getopt
(argv, “i:”, [‘ifile=’])

where opts contains [(‘-i’, /c:\\pyprg\\p4′)]
-i:- option nothing but mode should be followed by:
c:\\pyprg\ \p4′ value – the absolute path of C++ file.        ,

In our examples since the entire command line commands are parsed and no leftover argument, the second argument argswill be empty [ ].
If args is displayed using print () command it displays the output as [].

Question 5.
Write a Python program to execute the following C++ coding?
#include <iostream>
using namespace std;
int main( )
{ cout«“WELCOME”;
return (0);
}
The above C++ program is saved in a file welcome.cpp
Python program
Type in notepad and save as welcome.cpp
Answer:
#include<iostream>
using namespace std;
int main( )
{
cout<<“WELCOME”;
retum(0);
}
Open Notepad and type python program and save as welcome.py
import sys,os,getopt
def main(argv):
cppfile =”
exefile = ”
opts, args = getopt.getopt(argv, “i:”, [ifile = ‘])
for o,a in opts:
if o in (“_i”,” ifile “):
cpp_file = a+ ‘.cpp’
exe_file = a+ ‘.exe’
run(cpp_file, 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:])
Output:
——————-
WELCOME
——————-

12th Computer Science Guide Importing C++ Programs in Python Additional Questions and Answers

I. Choose the best answer (1 Marks)

Question 1.
Which one of the following language act as both scripting and general-purpose language?
(a) python
(b) c
(c) C++
(d) html
Answer:
(a) python

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 2.
_______ can act both as scripting and general-purpose language.
a) Python
b) C
c) C++
d) Html
Answer:
a) Python

Question 3.
Identify the script language from the following.
(a) Html
(b) Java
(c) Ruby
(d) C++
Answer:
(c) Ruby

Question 4.
language use automatic garbage collection?
a) C++
b) Java
c) C
d) Python
Answer:
d) Python

Question 5.
is required for the scripting language.
a) Compiler
b) Interpreter
c) Python
d) Modules
Answer:
b) Interpreter

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 6.
How many values can be returned by a function in python?
(a) 1
(b) 2
(c) 3
(d) many
Answer:
(d) many

Question 7.
is an expansion of MinGW
a) Minimalist Graphics for windows
b) Minimum GNU for windows
c) Minimalist GNU for Windows
d) Motion Graphics for windows
Answer:
c) Minimalist GNU for Windows

Question 8.
………….. is not a python module.
a) Sys
b) OS
c) Getopt
d) argv
Answer:
d) argv

Question 9.
Which of the following language codes are linked by MinGW on windows OS?
(a) C
(b) C++
(c) FORTRAN
(d) all of these
Answer:
(d) all of these

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 10.
is both a python-like language for writing C extensions.
a) Boost
b) Cython
c) SWIG
d) Ctypes
Answer:
b) Cython

Question 11.
refers to a set of runtime header files used in compiling and linking the C++ code to be run or window OS.
a) SWIG
b) MinGW
c) Cython
d) Boost
Answer:
b) MinGW

Question 12.
Which is a software design technique to split the code into separate parts?
a) Procedural programming
b) Structural programming
c) Object-Oriented Programming
d) Modular Programming
Answer:
d) Modular Programming

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 13.
Which refers to a file containing python statements and definitions?
a) Procedures
b) Modules
c) Structures
d) Objects
Answer:
b) Modules

Question 14.
Which symbol inos. system ( ) indicates that all strings are concatenated and sends that as a list.
a) +
b) .
c) ()
d) –
Answer:
a) +

Question 15.
The input mode in the python command is given by ………………………….
(a) -i
(b) o
(c) -p
Answer:
(a) -i

Question 16
the command is used to clear the screen in the command window.
a) els
b) Clear
c) Clr
d) Clrscr
Answer:
a) els

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 17.
The keyword used to import the module is
a) Include
b) Input
c) Import
d) None of these
Answer:
c) Import

Question 18.
Which in os.system( ) indicates that all strings are concatenated?
(a) +
(b) –
(c) #
(d) *
Answer:
(a) +

II. Answer the following questions (2 and 3 Marks)

Question 1.
Define wrapping.
Answer:
Importing a C++ program in a Python program is called wrapping up of C++ in Python.

Question 2.
Explain how to import C++ Files in Python.
Answer:
Importing C++ Files in Python:

  • Importing a C++ program in a Python program is called wrapping up of C++ in Python.
  • Wrapping or creating Python interfaces for C++ programs is done in many ways.

The commonly used interfaces are

  • Python-C-API (API-Application Programming Interface for interfacing with C programs)
  • Ctypes (for interfacing with c programs)
  • SWIG (Simplified Wrapper Interface Generator- Both C and C++)
  • Cython (Cython is both a Python-like language for writing C-extensions)
  • Boost. Python (a framework for interfacing Python and C++)
  • MinGW (Minimalist GNU for Windows)

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 3.
Define: g++
Answer:
g++ is a program that calls GCC (GNU C Compiler) and automatically links the required C++ library files to the object code.

Question 4.
Write a note on scripting language?
Answer:
A scripting language is a programming language designed for integrating and communicating with other programming languages. Some of the most widely used scripting languages are JavaScript, VBScript, PHP, Perl, Python, Ruby, ASP, and Tel.

Question 5.
What is garbage collection in python?
Answer:

  • Python deletes unwanted objects (built-in types or class instances) automatically to free the memory space.
  • The process by which Python periodically frees and reclaims blocks of memory that no longer are in use is called Garbage Collection.

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 6.
Define: GNU C compiler.
Answer:
g++ is a program that calls GCC (GNU C Compiler) and automatically links the required C++library files to the object code

Question 7.
Explain how to execute a C++ program through python using the MinGW interface? Give example
Answer:
Executing C++Program through Python: C:\Program Files\OpenOffiice 4\
Python.
cd<absolute path>

Question 8.
Write a note on

  1. cd command
  2. els command

Answer:

  1. cd command: The cd command refers to changes directory and absolute path refers to the complete path where Python is installed.
  2. els command: To clear the screen in the command window.

Question 9.
Define: Modular programming
Answer:

  • Modular programming is a software design technique to split your code into separate parts.
  • These parts are called modules. The focus for this separation should have modules with no or just a few dependencies upon other modules.

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 10.
Define

  1. sys module
  2. OS module
  3. getopt module

Answer:

  1. sys module provides access to some variables used by the interpreter and to functions that interact with the interpreter.
  2. OS module in Python provides a way of using operating system-dependent functionality.
  3. The getopt module of Python helps you to parse (split) command-line options and arguments.

Question 11.
Explain how to import modules and access the function inside the module in python?
Answer:

  • We can import the definitions inside a module to another module.
  • We use the import keyword to do this.
  • Using the module name we can access the functions defined inside the module.
  • The dot (.) operator is used to access the functions.
  • The syntax for accessing the functions from the module is < module name >

Example:
>>> factorial.fact(5)
120
Where
Factorial – Module name. – Dot Operator fact (5) – Function call

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 12.
Explain Module with suitable example
Answer:

  • Modules refer to a file containing Python statements and definitions.
  • A file containing Python code, for e.g. factorial.py, is called a module and its module name would be factorial.
  • We use modules to break down large programs into small manageable and organized files.
  • Modules provide reusability of code.
  • We can define our most used functions in a module and import it, instead of copying their definitions into different programs.

Example:
def fact(n): f=l
if n == 0:
return 0
elif n == 1:
return 1
else:
for i in range(l, n+1):
f= f*i
print (f)
Output:
>>>fact (5)
120

Question 13.
Write an algorithm for executing C++ program pali_cpp.cpp using python program.pall.py.
Answer:
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

Question 14.
Explain _name_ is one such special variable which by default stores the name of the file.
Answer:

  • _name_ is a built-in variable which evaluates the name of the current module.
  • Example: if _name_ == ‘_main _’: main

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

Question 15.
How Python is handling the errors in C++.
Answer:
Python not only execute the successful C++ program, but it also helps to display even errors if any in C++ statement during compilation.
Example:
// C++ program to print the message Hello
/ / Now select File—^New in Notepad and type the C++ program #include using namespace std; int main()
{
std::cout«/,hello// return 0;
}
/ / Save this file as hello.cpp
#Now select File → New in Notepad and type the Python program as main.py
#Program that compiles and executes a .cpp file
The output of the above program :

Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python

III. Answer the following questions (5 Marks)

Question 1.
a) Write a Python code to display all the records of the following table using fetchmany().

Reg No. Name Marks
3001 Chithirai 353
3002 Vaigasi 411
3003 Aani 374
3004 Aadi 289
3005 Aavani 407
3006 Purattasi 521

Python Program:
import sqlite3
connection = sqlite3.connect(” Academy.db”) cursor = connection.cursorQ student_data = [(‘3001″,”Chithirai”,”353″),
(‘3002″ ,”Vaigasii”,”411″),
(‘3003″,” Aani”,”374″),
(‘3004″,” Aadi”,”289″),
(‘3005″,”Aavanii”,”507″),
(‘3006″,”Purattasi”,”521″),]
for p in student_data:
format_str = “””INSERT INTO Student (Regno, Name, Marks) VALUES (“{regno}”,”{name}”,”{marks}”);”””
sql_command = format_str.format(regno=p[0], name=p[l], marks = p[4])
cursor.execute(sql_command)
cursor.execute(“SELECT * FROM student”)
result = cursor. fetchmany(6)
print(*result,sep=:”\n”) connection.commit() connection.close()

b) Write a Python Script to display the following Pie chart.
Samacheer Kalvi 12th Computer Science Guide Chapter 14 Importing C++ Programs in Python 2
Answer:
(Pie chart not given in question paper, Let us consider the following pie chart)
import matplotlib.pyplot as pit sizes = [89, 80, 90,100, 75]
labels = [“Tamil”, “English”, “Maths”, “Science”, “Social”]
plt.pie (sizes, labels = labels, autopet = “%.2f “)
plt.axes().set_aspect (“equal”)
plt.show()

Question 2.
Write a C++ program to check whether the given number is palindrome or not. Write a program to execute it?
Answer:
Example:- Write a C++ program to enter any number and check whether the number is palindrome or not using while loop.
/*. To check whether the number is palindrome or not using while loop.*/
//Now select File-> New in Notepad and type the C++ program
#include <iostream>
using namespace std; intmain( )
{
int n, num, digit, rev = 0;
cout << “Enter a positive number:”;
cin>>num;
n = num;
while(num)
{ digit=num% 10;
rev= (rev* 10) +digit;
num = num/10;
cout << “The reverse of the number is:”<<rev <<end1;
if (n ==rev)
cout<< “The number is a palindrome”;
else
cout<< “The number is a palindrome”;
return 0;
}
//save this file as pali_cpp.cpp
#Now select File → New in Notepad and type the Python program
#Save the File as pali.py.Program that complies and executes a .cpp file
import sys, os, getopt
def main(argv);
cpp_file=”
exe_file=”
opts.args = getopt.getopt(argv, “i:”,[‘ifile-])
for o, a in opts:
if o in (“-i”, “—file”):
cpp_file =a+ ‘.cpp’
exe_file =a+ ‘.exe’
run(cpp_file, exe_file)
def run(cpp_file, exe_file):
print(“Compiling” + eppfile)
os.system(‘g++’ + cpp_file +’ -o’ + exe file)
print(“Running” + exe_file)
print(“——————“)
print
os.system(exefile)
print
if_name_==’_main_’: #program starts executing from here
main(sys.argv[1:])
The output of the above program:
C:\Program Files\OpenOffice 4\program>Python c:\pyprg\pali.py -i c:\pyprg\pali_cpp
Compiling c:\pyprg\pali_cpp.cpp
Running c:\pyprg\pali_cpp.exe
———————————–
Enter a positive number: 56765
The reverse of the number is: 56765
The number is a palindrome
C:\Program Files\OpenOffice 4\program>Python c:\pyprg\pali.py -i c:\pyprg\pali_cpp Compiling c:\pyprg\pali_cpp.cpp Running c:\pyprg\pali_cpp.exe
Enter a positive number: 56756
The reverse of the number is: 65765
The number is not a palindrome
————————

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1

Tamilnadu State Board New Syllabus Samacheer Kalvi 12th Business Maths Guide Pdf Chapter 5 Numerical Methods Ex 5.1 Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 12th Business Maths Solutions Chapter 5 Numerical Methods Ex 5.1

Question 1.
Evaluate Δ (log ax).
Solution:
Δ log (ax) = log (ax + h) – log ax
= log [ \(\frac { ax+h }{ax}\) ] = log[\(\frac { ax }{ax}\) + \(\frac { h }{ax}\)]
= log [1 + \(\frac { h }{ax}\)]

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1

Question 2.
If y = x³ – x² + x -1 calculate the values of y for x= 0, 1, 2, 3, 4, 5 and form the forward differences table.
Solution:
Given y = x³ – x² + x – 1
when x = 0 y = -1
when x = 1
y = 1 – 1 + 1 – 1 = 0
when x = 2
y = 8 – 4 + 2 – 1 = 5
for x = 0, 1, 2, 3, 4, 5
when x = 3
y = 27 – 9 + 3 – 1 = 20
when x = 4
y = 64 – 16 + 4 – 1 = 51
when x = 5
y = 125 – 25 + 5 – 1 = 104
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1 1

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1

Question 3.
If h = 1 then prove that (E-1 Δ)x³ = 3x² – 3x + 1
Solution:
h = 1 To prove (E-1 ∆) x3 = 3×2 – 3x + 1
L.H.S = (E-1 ∆) x3 = E-1 (∆x3)
= E-1[(x + h)3 – x3]
= E-1( x + h)3 – E-1(x3)
= (x – h + h)3 – (x – h)3
= x3 – (x – h)3
But given h = 1
So(E-1 ∆) x3 = x3 – (x – 1)3
= x3 – [x3 – 3x2 + 3x – 1]
= 3x2 – 3x + 1
= RHS

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1

Question 4.
If f(x) = x² + 3x than show that Δf(x) = 2x + 4
Solution:
Given f(x) = x³ + 3x; h = 1
Δf(x) = f (x + h) – f(x)
= (x + 1)² + 3 (x + 1) – (x² + 3x)
= x² + 2x + 1 + 3x + 3 – x² + 3x
= 2x + 4
∴ Δf(x) = 2x + 4

Question 5.
Evaluate Δ [ \(\frac { 1 }{(x+1)+(x+2)}\) ] by taking ‘1’ as the interval of differencing
Solution:
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1 2

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1

Question 6.
Find the missing entry in the following table
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1 3
Solution:
Since only four values of f(x) are given the polynomial which fits the data is of degree three. Hence fourth differences are zeros.
(ie) Δ4 y0 = 0
(E – 1)4 y0 = 0
(E4 – 4E³ + 6E² – 4E + 1) y0 = 0
E4y0 – 4E³ y0 + 6E²y0 – 4E y0 + 1y0 = 0
y4 – 4y3 + 6y2 – 4y1+ y0 = o
81 – 4y3 + 6(9) – 4(3) + 1 = 0
81 – 4y3 + 54 – 12 + 1 = 0
136 – 12 – 4y3 = 0
4y3 = 124
y3 = \(\frac { 124 }{4}\)
∴ y3 = 31

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1

Question 7.
Following are the population of a district
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1 4
Find the population of the year 1911
Solution:
Since only five values of fix) are given, the polynomial which fits the data is of degree four. Hence fifth differences are zeros.
(ie) Δ5 y0 = 0
(E – 1)5 y0 = 0
(E5 – 5E4 + 10E³ – 10E² + 5E – 1) y0 = 0
E5y0 – 5E4y0 + 10E³y0 – 10E²y0 + 5E y0 – y0 = 0
y5 – 5y4 + 10y3 – 10y2 + 5y1 – y0 = 0
501 – 5 (467) + 10(y3) -10 (421) + 5 (391) – 363 = 0
2456 – 6908 + 10y3 = 0
-4452 + 10y3 = 0 ⇒ 10y3 = 4452
y = \(\frac { 4452 }{10}\) = 445.2
The population of the year 1911 is 445.2 thousands

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1

Question 8.
Find the missing entries from the following.
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1 5
Solution:
Since four values of f(x) are given we assume the polynomial of degree three. Hence fourth order differences are zeros.
(ie) Δ4y0 = 0 (ie) (E – 1)4 yk = 0
(E4 – 4E³ + 6E² – 4E + 1) yk = 0 ……… (1)
Put k = 0 in (1)
(E4 – 4E³ + 6E² – 4E + 1) y0 = 0
E4y0 – 4E³y0 + 6E³y0 – 4Ey0 + y0 = 0
y4 – 4y3 + 6y2 – 4y1 + y0 = 0
y4 – 4 (15) + 6(8) – 4y1 + 0 = 0
y4 – 4y1 = 12 …….. (2)
Put k = 1 in eqn (1)
(E4 – 4E³ + 6E² – 4E + 1) y1 = 0
y5 – 4y4 + 6y3 – 4y2 + y1 = 0
35 – 4 (y4) + 6(15) – 4(8) + y1 = 0
35 – 4y4 + 90 – 32 + y1 = 0
-4y4 + y1 + 125 – 32 = 0
-4y4 + y1 = -93 ………. (3)
Solving eqn (2) & (3)
Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1 6
Substitute y = 3 in eqn (2)
y4 – 4(3) = 12
y4 – 12 = 12
y4 = 12 + 12
∴ y4 = 24
The required two missing entries are 3 and 24.

Samacheer Kalvi 12th Business Maths Guide Chapter 5 Numerical Methods Ex 5.1

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Tamilnadu State Board New Syllabus Samacheer Kalvi 12th Computer Science Guide Pdf Chapter 15 Data Manipulation Through SQL Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 12th Computer Science Solutions Chapter 15 Data Manipulation Through SQL

12th Computer Science Guide Data Manipulation Through SQL Text Book Questions and Answers

I. Choose the best answer (I Marks)

Question 1
Which of the following is an organized collection of data?
a) Database
b) DBMS
c) Information
d) Records
Answer:
a) Database

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 2.
SQLite falls under which database system?
a) Flat file database system
b) Relational Database system
c) Hierarchical database system
d) Object oriented Database system
Answer:
b) Relational Database system

Question 3.
Which of the following is a control structure used to traverse and fetch the records of the database?
a) Pointer
b) Key
c) Cursor
d) Insertion point
Answer:
c) Cursor

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 4.
Any changes made in the values of the record should be saved by the command
a) Save
b) Save As
c) Commit
d) Oblige
Answer:
c) Commit

Question 5.
Which of the following executes the SQL command to perform some action?
a) execute()
b) Key()
c) Cursor()
d) run()
Answer:
a) execute()

Question 6.
Which of the following function retrieves the average of a selected column of rows in a table?
a) Add()
b) SUM()
c) AVG()
d) AVERAGE()
Answer:
c) AVG()

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 7.
The function that returns the largest value of the selected column is
a) MAX()
b) LARGE ()
c) HIGH ()
d) MAXIMUM ()
Answer:
a) MAX()

Question 8.
Which of the following is called the master table?
a) sqlite_master
b) sql_master
c) main_master
d) master_main
Answer:
a) sqlite_master

Question 9.
The most commonly used statement in SQL is
a) cursor
b) select
c) execute
d) commit
Answer:
b) select

Question 10.
Which of the following clause avoid the duplicate?
a) Distinct
b) Remove
c) Wher
d) Group By
Answer:
a) Distinct

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

II. Answer the following questions (2 Marks)

Question 1.
Mention the users who use the Database.
Answer:
Users of databases can be human users, other programs, or applications.

Question 2.
Which method is used to connect a database? Give an example.
Answer:

  • Connect()method is used to connect a database
  • Connecting to a database means passing the name of the database to be accessed.
  • If the database already exists the connection will open the same. Otherwise, Python will open a new database file with the specified name.

Example:
import sqlite3
# connecting to the database
connection = sqlite3.connect (“Academy.db”)
# cursor
cursor = connection. cursor()

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 3.
What is the advantage of declaring a column as “INTEGER PRIMARY KEY”
Answer:
If a column of a table is declared to be an INTEGER PRIMARY KEY, then whenever a NULL will be used as an input for this column, the NULL will be automatically converted into an integer which will one larger than the highest value so far used in that column. If the table is empty, the value 1 will be used.

Question 4.
Write the command to populate record in a table. Give an example.
Answer:

  • To populate (add record) the table “INSERT” command is passed to SQLite.
  • “execute” method executes the SQL command to perform some action.

Example:
import sqlite3
connection = sqlite3.connect
(“Academy.db”)
cursor = connection.cursor()
CREATE TABLE Student ()
Rollno INTEGER PRIMARY KEY,
Sname VARCHAR(20), Grade CHAR(1),
gender CHAR(l), Average DECIMAL
(5,2), birth_date DATE);”””
cursor.execute(sql_command)
sqLcommand = “””INSERT INTO Student (Rollno, Sname, Grade, gender, Average, birth_date)
VALUES (NULL, “Akshay”, “B”, “M”, “87.8”, “2001-12-12″);”””
cursof.execute(sql_ command) sqLcommand .= “””INSERT INTO Student \ (Rollno, Sname, Grade, gender, Average, birth_date)
VALUES (NULL, “Aravind”, “A”, “M”, “92.50”,”2000-08-17″);””” cursor.execute (sql_ command)
#never forget this, if you want the changes to be saved:
connection.commit()
connection.close()
print(“Records are populated”)
OUTPUT:
Records are populated

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 5.
Which method is used to fetch all rows from the database table?
Answer:
Displaying all records using fetchall( )
The fetchall( ) method is used to fetch all rows from the database table
result = cursor.fetchall( )

III. Answer the following questions (3 Marks)

Question 1.
What is SQLite? What is its advantage?
Answer:

  • SQLite is a simple relational database system, which saves its data in regular data files or even in the internal memory of the computer.
  • SQLite is designed to be embedded in applications, instead of using a separate database server program such as MySQL or Oracle.
  • SQLite is fast, rigorously tested, and flexible, making it easier to work.

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 2.
Mention the difference between fetchone() and fetchmany().
Answer:

fetchone() fetchmany()
The fetchone() method returns the next row of a query result set fetchmany() method returns the next number of rows (n) of the result set. .
Example: r=cursor. fetchoneQ Example: r=cursor. fetchmanyQ)

Question 3.
What is the use of the Where Clause? Give a python statement Using the where clause.
Answer:

  • The WHERE clause is used to extract only those records that fulfill a specified condition.
  • The WHERE clause can be combined with AND, OR, and NOT operators.
  • The AND and OR operators are used to filter records based on more than one condition.

Example:
import sqlite3
connection = sqlite3.
connect(“Academy, db”)
cursor = connection. cursor()
cursor, execute (“SELECT DISTINCT (Grade) FROM student where gender=’M'”)
result = cursor. fetchall()
print(*result, sep=”\n”)
OUTPUT:
(‘B’,)
(‘A’,)
(‘C’,)
(‘D’,)

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 4.
Read the following details. Based on that write a python script to display department wise records.
Database name: organization, db
Table name: Employee
Columns in the table: Eno,
EmpName,
Esal, Dept

Contents of Table: Employee

Eno EmpName Esal Dept
1001 Aswin 28000 IT
1003 Helena 32000 Accounts
1005 Hycinth 41000 IT

Coding:
import sqlite3
connection = sqlite3. connect
(” organization, db”)
cursor = connection, cursor ()
sqlcmd=””” SELECT *FROM
Employee ORDER BY Dept”””
cursor, execute (sqlcmd)
result = cursor, fetchall ()
print (“Department wise Employee List”)
for i in result:
print(i)
connection. close()
Output:
Department wise Employee List
(1003,’Helena’,32000, ‘Accounts’)
(1001,’Aswin’,28000,’IT’)
(1005,’Hycinth’,41000,’IT’)

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 5.
Read the following details.Based on that write a python script to display records in desending order of Eno
Database name : organization.db
Table name : Employee
Columns in the table : Eno, EmpName, Esal, Dept
Contents of Table: Employee

Eno EmpName Esal Dept
1001 Aswin 28000 IT
1003 Helena 32000 Accounts
1005 Hycinth 41000 IT

Coding:
import sqlite3
connection = sqlite3 . connect
(“organization, db”)
cursor = connection, cursor ()
cursor, execute (“SELECT *
FROM Employee ORDER BY Eno DESC”)
result = cursor, fetchall ()
print (“Department wise
Employee List in descending order:”)
for i in result:
print(i)
connection.close()
Output:
Department wise Employee List in descending order:
(1005,’Hycinth’,41000,’IT’)
(1003,’Helena’,32000, ‘Accounts’)
(1001,’Aswin’,28000,’IT’)

IV. Answer the following questions (5 Marks)

Question 1.
Write in brief about SQLite and the steps used to use it.
Answer:
SQLite is a simple relational database system, which saves its data in regular data files or even in the internal memory of the computer. It is designed to be embedded in applications, instead of using a separate database server program such as MySQL or Oracle. SQLite is fast, rigorously tested, and flexible, making it easier to work. Python has a native library for SQLite. To use SQLite,
Step 1 import sqliteS
Step 2 create a connection using connect ( ) method and pass the name of the database File
Step 3 Set the cursor object cursor = connection.cursor( )

  1. Connecting to a database in step2 means passing the name of the database to be accessed. If the database already exists the connection will open the same. Otherwise, Python will open a new database file with the specified name.
  2. Cursor in step 3: is a control structure used to traverse and fetch the records of the database.
  3. Cursor has a major role in working with Python. All the commands will be executed using cursor object only.

To create a table in the database, create an object and write the SQL command in it.
Example:- sql_comm = “SQL statement”
For executing the command use the cursor method and pass the required sql command as a parameter. Many commands can be stored in the SQL command can be executed one after another. Any changes made in the values of the record should be saved by the command “Commit” before closing the “Table connection”.

Question 2.
Write the Python script to display all the records of the following table using fetchmany()

Icode ItemName Rate
1003 Scanner 10500
1004 Speaker 3000
1005 Printer 8000
1008 Monitor 15000
1010 Mouse 700

Answer:
Database : supermarket
Table : electronics
Python Script:
import sqlite3
connection = sqlite3.connect
(” supermarket. db”)
cursor = connection.cursor()
cursor.execute
(“SELECT * FROM electronics “)
print(“Fetching all 5 records :”)
result = cursor.fetchmany(5)
print(*result,sep=” \ n”)
Output:
Fetching all 5 records :
(1003,’Scanner’ ,10500)
(1004,’Speaker’,3000)
(1005,’Printer’,8000)
(1008,’Monitor’,15000)
(1010,’Mouse’,700)

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 3.
What is the use of HAVING clause. Give an example python script.
Answer:
Having clause is used to filter data based on the group functions. This is similar to WHERE condition but can be used only with group functions. Group functions cannot be used in WHERE Clause but can be used in HAVING clause.
Example
import sqlite3
connection= sqlite3.connect(“Academy.db”)
cursor = connection. cursor( )
cursor.execute(“SELECT GENDER,COUNT(GENDER) FROM Student GROUP BY GENDER HAVING COUNT(GENDER)>3 “)
result = cursor. fetchall( )
co= [i[0] for i in cursor, description]
print(co)
print( result)
OUTPUT
[‘gender’, ‘COUNT(GENDER)’]
[(‘M’, 5)]

Question 4.
Write a Python script to create a table called ITEM with the following specifications.
Add one record to the table.
Name of the database: ABC
Name of the table :- Item
Column name and specification :-
Icode : integer and act as primary key
Item Name : Character with length 25
Rate : Integer
Record to be added : 1008, Monitor, 15000
Answer:
Coding:
import sqlite3
connection = sqlite3 . connect (“ABC.db”)
cursor = connection, cursor ()
sql_command = ” ” ”
CREATE TABLE Item (Icode INTEGER,
Item_Name VARCHAR (25),
Rate Integer); ” ‘” ”
cursor, execute (sql_command)
sql_command = ” ” “INSERT INTO Item
(Icode,Item_name, Rate)VALUES (1008,
“Monitor”, “15000”);” ” ”
cursor, execute (sqlcmd)
connection, commit ()
print(“Table Created”)
cursor. execute(SELECT *FROM ITEM”)
result=cursor.fetchall():
print(“CONTENT OF THE TABLE
print(*result,sep=”\n”)
connection, close ()
Output:
Table Created
CONTENT OF THE TABLE :
(1008, ‘Monitor’, 15000)

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 5.
Consider the following table Supplier and item.
Write a python script for
i) Display Name, City and Item name of suppliers who do not reside in Delhi.
ii) Increment the SuppQty of Akila by 40
Name of the database : ABC
Name of the table : SUPPLIER

Suppno Name City Icode SuppQty
S001 Prasad Delhi 1008 100
S002 Anu Bangalore 1010 200
S003 Shahid Bangalore 1008 175
S004 Akila Hydrabad 1005 195
S005 Girish Hydrabad 1003 25
S006 Shylaja Chennai 1008 180
S007 Lavanya Mumbai 1005 325

i) Display Name, City and Itemname of suppliers who do not reside in Delhi:
Coding:
import sqlite3
connection = sqlite3.
connection/’ABC.db”)
cursor = connection, cursor ()
sqlcmd=”””(“SELECT SUPPLIER. Name,SUPPLIER.City,Item.ItemName FROM SUPPLIER,Item WHERE SUPPLIER.City NOT IN(“Delhi”) and SUPPLIER.Icode=Item.Icode” ” ”
cursor, execute(sqlcmd)
result = cursor.fetchall()
print(” Suppliers who do not reside in Delhi:”)
for r in result:
print(r)
conn.commit ()
conn, close ()
Output:
Suppliers who do not reside in Delhi:
(‘ Anu’ / Bangalore’/Mouse’)
(‘Shahid7,’Bangalore7,’Monitor’)
(‘Akila’/Hydrabad’,’Printer’)
(‘Girish’/Hydrabad’/Scanner’)
(‘Shylaja’/Chennai’/Monitor’)
(‘ La vanya’/ Mumbai’/ Printer’)

ii) Increment the SuppQty of Akila by 40: import sqlite3
connection = sqlite3.
connection/’ABC.db”)
cursor = connection, cursor ()
sqlcmd=”””UPDATE SUPPLIER
SET Suppqty=Suppqty+40 WHERE
Name=’Akila”””
cursor, execute(sqlcmd)
result = cursor.fetchall()
print
(“Records after SuppQty increment:”)
for r in result:
print(r)
conn.commit ()
conn, close ()
Output:
Records after SuppQty increment:
(‘S001′ /PrasadVDelhi’,1008,100)
(‘S002′ ,’Anu’ /Bangalore’,1010,200)
(‘S003′ /Shahid’/Bangalore’, 1008,175)
(‘S004’/Akila’/Hydrabad’,1005,235)
(‘S005′ /Girish’/Hydrabad’, 003,25)
(‘S006′ /Shylaja’/Chennai’,1008,180)
(‘S007′ ,’Lavanya’,’Mumbai’,1005,325)

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

12th Computer Science Guide Data Manipulation Through SQL Additional Questions and Answers

I. Choose the best answer (I Marks)

Question 1.
…………………… command is used to populate the table.
a) ADD
b) APPEND
c) INSERT
d) ADDROW
Answer:
c) INSERT

Question 2.
Which has a native library for SQLite?
(a) C
(b) C++
(c) Java
(d) Python
Answer:
(d) Python

Question 3.
………………….. method is used to fetch all rows from the database table.
a) fetch ()
b) fetchrowsAll ()
c) fectchmany ()
d) fetchall ()
Answer:
d) fetchall ()

Question 4.
………………….. method is used to return the next number of rows (n) of the result set.
a) fetch ()
b) fetchmany ()
c) fetchrows ()
d) tablerows ()
Answer:
b) fetchmany ()

Question 5.
How many commands can be stored in the sql_comm?
(a) 1
(b) 2
(c) 3
(d) Many
Answer:
(d) Many

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 6.
…………………..clause is used to extract only those records that fulfill a specified condition.
a) WHERE
b) EXTRACT
c) CONNECT
d) CURSOR
Answer:
a) WHERE

Question 7.
…………………..clause is used to sort the result-set in ascending or descending order.
a) SORT
b) ORDER BY
c) GROUP BY
d) ASC SORT
Answer:
b) ORDER BY

Question 8.
………………….. clause is used to filter database on the group functions?
a) WHERE
b) HAVING
c) ORDER
d) FILTER
Answer:
b) HAVING

Question 9.
What will be the value assigned to the empty table if it is given Integer Primary Key?
(a) 0
(b) 1
(c) 2
(d) -1
Answer:
(b) 1

Question 10.
The sqlite3 module supports ………………. kinds of placeholders:
a) 1
b) 2
c) 3
d) 5
Answer:
b) 2

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 11.
……………… has a native library of SQlite.
a) Python
b) C++
c) Java
d) C
Answer:
a) Python

Question 12.
All the SQlite commands will be executed using……………… object only
a) connect
b) cursor
c) CSV
d) python
Answer:
b) cursor

Question 13.
Which method returns the next row of a query result set?
(a) Fetch ne( )
(b) fetch all( )
(c) fetch next( )
(d) fetch last( )
Answer:
(a) Fetch ne( )

Question 14.
…………… function returns the number of rows in a table satisfying the criteria specified in the WHERE clause.
a) Distinct
b) count
c) Having
d) Counter
Answer:
b) count

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 15.
Count () returns …………… if there were no matching rows.
a) 0
b) 1
c) NOT NULL
d) NULL
Answer:
a) 0

Question 16.
…………… contains the details of each column headings
a) cursor, description
b) cursor.connect
c) cursor.column
d) cursor.fieldname
Answer:
a) cursor, description

Question 17.
Which one of the following is used to print all elements separated by space?
(a) ,
(b) .
(c) :
(d) ;
Answer:
(a) ,

II. Answer the following questions (2 and 3 Marks)

Question 1.
Write the SQLite steps to connect the database.
Answer:
Step 1: Import sqlite3
Step 2: Create a connection using connect o method and pass the name of the database file.
Step 3 : Set the cursor object cursor = connection, cursor ()

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 2.
Mention the frequently used clauses in SQL?
Answer:

  1. DISTINCT
  2. WHERE
  3. GROUP BY
  4. ORDER BY
  5. HAVING

Question 3.
Write a Python code to create a database in SQLite.
Answer:
Python code to create a database in SQLite:
import sqlite3
connection = sqlite3.connect (“Academy.db”)
cursor + connection.cursorQ

Question 4.
Define: sqlite_master
Answer:
sqlite_master is the master table which holds the key information about the database tables.

Question 5.
Give a short note on GROUP BY class.
Answer:

  • The SELECT statement can be used along with the GROUP BY clause.
  • The GROUP BY clause groups records into summary rows. It returns one record for each group.
  • It is often used with aggregate functions (COUNT, MAX, MIN. SUM, AVG) to group the result -set by one or more columns.

Question 6.
Write short notes on

  1. COUNT ()
  2. AVG ()
  3. SUM ()
  4. MAX ()
  5. MIN ()

Answer:

  1. COUNT ( ) function returns the number of rows in a table.
  2. AVG () function retrieves the average of a selected column of rows in a table.
  3. SUM () function retrieves the sum of a selected column of rows in a table.
  4. MAX( ) function returns the largest value of the selected column.
  5. MIN( ) function returns the smallest value of the selected column.

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 7.
Write a program to count the number of male and female students from the student table
Example
Answer:
import sqlite3
connection= sqlite3.connect(“Academy.db”)
cursor = connection.cursor( )
cursor.execute(“SELECT gender,count(gender) FROM student Group BY gender”)
result = cursor. fetchall( )
print(*result,sep=”\n”)
OUTPUT
(‘F’, 2)
(‘M’, 5)

Question 8.
Explain Deletion Operation with a suitable example.
Answer:
Deletion Operation:
Similar to Sql command to delete a record, Python also allows to delete a record.
Example: Coding to delete the content of Rollno 2 from “student table”

Coding:
# code for delete operation
import sqlite3
# database name to be passed as parameter
conn = sqlite3.connect(“Academy.db”)
# delete student record from database
conn.execute(“DELETE from Student
where Rollno=’2′”)
conn.commitQ
print(“Total number of rows deleted conn.total_changes)
cursor =conn.execute(“SELECT * FROM
Student”)
for row in cursor:
print(row)
conn.close()
OUTPUT:
Total number of rows deleted : 1
(1, ‘Akshay’, ‘B’, ‘M’, 87.8, ‘2001-12-12’)
(3, ‘BASKAR’, ‘C’, ‘M’, 75.2, ‘1998-05-17’)
(4, ‘SAJINI’, ‘A’, ‘F, 95.6, ‘2002-11-01’)
(5, ‘VARUN’, ‘B’, ‘M’, 80.6, ‘2001-03-14’)
(6, ‘Priyanka’, ‘A’, ‘F, 98.6, ‘2002-01-01’)
(7, ‘TARUN’, ‘D’, ‘M’, 62.3, ‘1999-02-01’)

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 9.
Explain Table List with suitable example.
Answer:
Program to display the list of tables created in a database:
Coding:
import sqlite3
con = sqlite3.connect(‘Academy.db’)
cursor = con.cursor()
cursor.execute(“SELECT name FROM sqlite_master WHERE type=’table’;”) print(cursor.fetchall())
OUTPUT:
[(‘Student’,), (‘Appointment’,), (‘Person’,)]

Question 10.
Write a short note on cursor. fetchall(),cursor.fetchone(),cursor. fetchmany()
Answer:
cursor.fetchall():
cursor.fetchall() method is to fetch all rows from the database table .
cursor.fetchone():
cursor.fetchone() method returns the next row of a query result set or None in case there is no row left. cursor.fetchmany:
cursor.fetchmany() method that returns the next number of rows (n) of the result set

Question 11.
How to create a database using SQLite? Creating a Database using SQLite:
Answer:
# 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()
In the above example a database with the name “Academy” would be created. It’s similar to the sql command “CREATE DATABASE Academy;”

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 12.
Explain fetchall() to display all records with suitable examples?
Answer:
Displaying all records using fetchall():
The fetchall() method is used to fetch all rows from the database table.

Example:
import sqlite3
connection = sqlite3.connect(” Academy.db”)
cursor = connection.cursor()
cursor.execute(“SELECT FROM student”)
print(“fetchall:”)
result = cursor.fetchall()
for r in result:
print(r)
OUTPUT:
fetchall:
(1, ‘Akshay’, ‘B’, ‘M’, 87.8, ‘2001-12-12’)
(2, ‘Aravind’, ‘A’, ‘M’, 92.5, ‘2000-08-17’)
(3, ‘BASKAR’, ‘C’, ‘M’, 75.2, ‘1998-05-17’)
(4, ‘SAJINT, ‘A’, ‘F’, 95.6, ‘2002-11-01’)
(5, ‘VARUN’, ‘B’, ‘M’, 80.6, ‘2001-03-14’)
(6, ‘PRIYA’, ‘A’, ‘F’, 98.6, ‘2002-01-01’)
(7, ‘TARUN’, ‘D’, ‘M’, 62.3, ‘1999-02-01’)

Question 13.
Explain fetchone() to display a single record(one row) with a suitable example?
Answer:
Displaying A record using fetchone():
The fetchoneQ method returns the next row of a query result set or None in case there is no row left.

Example:
import sqlite3
connection = sqlite3.
connect(” Academy.db”)
cursor = connection.cursor()
cursor.execute(“SELECT * FROM student”)
print(“\nfetch one:”)
res = cursor.fetchone()
print(res)
OUTPUT:
fetch one:
(1, ‘Akshay’, ‘B’, ‘M’, 87.8, ‘2001-12-12’)

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 14.
Explain fetchone() to display all records with suitable examples?
Answer:
Displaying all records using fetchone(): Using while ioop and fetchone() method we can display all the records from a table.

Example:
import sqlite3
connection = sqlite3 .connect(” Academy. db”)
cursor = connection.cursor()
cursor.execute(”SELECT * FROM student”)
print(“fetching all records one by one:”)
result = cursor.fetchone()
while result is not None:
print(result)
result = cursor.fetchone()
OUTPUT:
fetching all records one by one:
(1, ‘Akshay’, ‘B’, ‘M’, 87.8, ‘2001-12-12’)
(2, ‘Aravind’, ‘A’, ‘M’, 92.5, ‘2000-08-17’)
(3, ‘BASKAR’, ‘C’, ‘M’, 75.2, ‘1998-05-17’)
(4, ‘SAJINI’, ‘A’, ‘F’, 95.6, ‘2002-11-01’)
(5, ‘VARUN’, ‘B’, ‘M’, 80.6, ‘2001-03-14’)
(6, ‘PRIYA’, ‘A’, ‘F’, 98.6, ‘2002-01-01’)
(7, ‘TARUN’, ‘D’, ‘M’, 62.3, ‘1999-02-01’)
Chapter 15.indd 297 70-02-2019 15:40:10

Question 15.
Explain fetchmany() to display a specified number of records with suitable example?
Answer:
Displayingusing fetchmany():
Displaying specified number of records is done by using fetchmany(). This method returns the next number of rows (n) of the result set.

Example : Program to display the content of tuples using fetchmany()
import sqlite3 .
connection = sqlite3. connect
(” Academy, db”)
cursor = connection.cursor()
cursor.execute
(“SELECT FROM student”)
print(“fetching first 3 records:”)
result = cursor.fetchmany(3)
print(result)
OUTPUT:
fetching first 3 records:
[(1, ‘Akshay’, ‘B’, ‘M’, 87.8, ‘2001-12-12′),
(2,’ Aravin d’, ‘A’, ‘M’, 92.5, /2000-08-17′),
(3, ‘BASKAR’, ‘C’, ‘M’, 75.2, ‘1998-05-17’)]

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

II. Answer the following questions (5 Marks)

Question 1.
Explain clauses in SQL with suitable examples.
Answer:

  • SQL provides various clauses that can be used in the SELECT statements.
  • These clauses can be called through a python script.
  • Almost all clauses will work with SQLite.

The various clauses is:

  • DISTINCT
  • WHERE
  • GROUPBY
  • ORDER BY.
  • HAVING

Data of Student table:
The columns are Rollno, Sname, Grade,
gender, Average, birth_date
(1, ‘Akshay’, ‘B’, ‘M’, 87.8, ‘2001-12-12’)
(2, ‘Aravind’, ‘A’, ‘M’, 92.5, ‘2000-08-17’)
(3, ‘BASKAR’, ‘C’, ‘M’, 75.2, ‘1998-05-17’)
(4, ‘SAJINT, ‘A’, ‘F’, 95.6, ‘2002-11-01’)
(5, ‘VARUN’, ‘B’, ‘M’, 80.6, ‘2001-03-14’)
(6, ‘PRIYA’, ‘A’, ‘F’, 98.6, ‘2002-01-01’)
(7, ‘TARUN’, ‘D’, ‘M’, 62.3, ‘1999-02-01’)

i) SQL DISTINCT CLAUSE

  • The distinct clause is helpful when there is a need of avoiding the duplicate values present in any specific columns/ table.
  • When we use a distinct keyword only the unique values are fetched.

Example:
Coding to display the different grades scored by students from “student table”:

import sqlite3
connection = sqlite3.connect(” Academy, db”)
cursor = connection.cursorQ cursor.execute(“SELECT DISTINCT (Grade) FROM student”)
result = cursor.fetchall()
print (result)
OUTPUT:
[(‘B’,), (‘A’,), (‘C’,), (‘D’,)]

Without the keyword “distinct” in the “Student table” 7 records would have been displayed instead of 4 since in the original table there are actually 7 records and some are with duplicate values.

ii) SQL WHERE CLAUSE
The WHERE clause is used to extract only those records that fulfill a specified condition.

Example:
Coding to display the different grades scored by male students from “student table”.
import sqlite3
connection = sqlite3.connec
(“Academy.db”)
cursor = connection.cursor()
cursor.execute(” SELECT DISTINCT i (Grade) FROM student where gender=’M”)
result = cursor.fetchall()
print(*result/sep=”\n”)
OUTPUT:
(‘B’,)
(‘A’,)
(‘C’,)
(‘D’,)

iii) SQL GROUP BY Clause :

  • The SELECT statement can be used along with the GROUP BY clause.
  • The GROUP BY clause groups records into summary rows.
  • It returns one records for each group,
  • It is often used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the result-set by one or more columns.

Example:
Coding to count the number of male and ; female from the student table and display j the result.

Coding:
import sqlite3;
connection = sqlite3.connect(“Academy.db”)
cursor = connection.cursor()
cursor.execute(“SELECT gender,count(gender) FROM student Group BY gender”)
result = cursor.fetchall() j
print(*result,sep=”\n”)
OUTPUT:
(‘F’, 2)
(‘M’, 5)

iv) SQL ORDER BY Clause

  • The ORDER BY clause can be used along with the SELECT statement to sort the data of specific fields in an ordered way.
  • It is used to sort the result-set in ascending or descending order.

Example
Coding to display the name and Rollno of the students in alphabetical order of names . import sqlite3
connection = sqlite3.connect(” Academy.db”)
cursor = connection.cursor()
cursor.execute(“SELECT Rollno,sname FROM student Order BY sname”)
result = cursor.fetchall()
print (*result, sep=” \ n”)
OUTPUT
(1, ‘Akshay’)
(2, ‘Aravind’)
(3, ‘BASKAR’)
(6, ‘PRIYA’)
(4, ‘SAJINI’)
(7, ‘TARUN’)
(5, ‘VARUN’)

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

v) SQL HAVING Clause

  • Having clause is used to filter data based on the group functions.
  • Having clause is similar to WHERE condition but can be used only with group functions.
  • Group functions cannot be used in WHERE Clause but can be used in HAVING clause.

Example:
import sqlite3
connection = sqlite3.connect(” Academy, db”)
cursor = connection.cursor()
cursor.execute(“SELECT GENDER,COUNT(GENDER) FROM Student GROUP BY GENDER HAVING COUNT(GENDER)>3”)
result = cursor.fetchall()
co = [i[0] for i in cursor, description]
print(co)
print(result)
OUTPUT:
[‘gender7,’ COUNT (GENDER)’ ]
[(‘M’, 5)]

Question 2.
Write a python program to accept 5 students’ names, their ages, and ids during run time and display all the records from the table?
Answer:
In this example we are going to accept data using Python input() command during runtime and then going to write in the Table called “Person”
Example
# code for executing query using input data
import sqlite3
#creates a database in RAM
con =sqlite3.connect(“Academy,db”)
cur =con.cursor( )
cur.execute(“DROP Table person”)
cur.execute(“create table person (name, age, id)”)
print(“Enter 5 students names:”)
who =[input( ) for i in range(5)]
print(“Enter their ages respectively:”)
age =[int(input()) for i in range(5)]
print(“Enter their ids respectively:”)
p_d =[int(input( ))for i in range(5)]
n =len(who)
for i in range(n):
#This is the q-mark style:
cur.execute(“insert into person values(?,?,?)”, (who[i], age[i], p_id[i]))
#And this is the named style:
cur.execute(“select *from person”)
#Fetches all entries from table
print(“Displaying All the Records From Person Table”)
print (*cur.fetchall(), sep=’\n’)
OUTPUT
Enter 5 students names:
RAM
KEERTHANA
KRISHNA
HARISH
GIRISH
Enter their ages respectively:
28
12
21
18
16
Enter their ids respectively:
1
2
3
4
5
Displaying All the Records From Person Table
(‘RAM’, 28, 1)
(‘KEERTHANA’, 12, 2)
(‘KRISHNA’, 21, 3)
(‘HARISH’, 18,4)
(‘GIRISH’, 16, 5)

Samacheer Kalvi 12th Computer Science Guide Chapter 15 Data Manipulation Through SQL

Question 3.
Write a Python program to store and retrieve the following data in SQLite3.
Database Schema:

Field Type Size Constrain
Rollno INTEGER PRIMARY KEY
Sname VARCHAR 20
Gender CHAR 1
Average DECIMAL 5,2

Date to be inserted as tuple:

Rolling Sname Gender Average
1001 KULOTHUNGAN
1002 KUNDAVAI
1003 RAJARAJAN
1004 RAJENDRAN
1005 AVVAI

Answer:
Python Program:
import sqlite3
connection = sqlite3.connect (“Academy.db”)
cursor = connection.cursor()
cursor.execute (“””DROP TABLE Student;”””)
sql_command = “”” CREATE TABLE Student ( Rollno INTEGER PRIMARY KEY ,
Sname VARCHAR(20), Grade CHAR(l), gender CHAR(l), Average DECIMAL (5, 2));””” cursor.execute(sql_command)
sql_command = “””INSERT INTO Student VALUES (1001, “KULOTHUNGAN”, “M”, “75.2”);”””
sql_command = “””INSERT INTO Student VALUES (1002, “KUNDAVAI”, “F”, “95.6”);”””
sql_command = “””INSERT INTO Student VALUES (1003, “RAJARAJAN”, “M”, “80.6”);”””
sql_command = “””INSERT INTO Student VALUES (1004, “RAJENDRAN”, “M”, “98.6”);”””
sql_command = “””INSERT INTO Student VALUES (1005, “AVVAI”, “F”, “70.1”);”””
cursor.execute (sql_ command)
connection.commit()
connection.close()