0% found this document useful (0 votes)
15 views193 pages

12CS_EM_2025

The document is a guide for computer science students, emphasizing simplicity and clarity in answers to help achieve full marks in examinations. It includes various chapters with questions and answers, QR codes for additional resources, and is authored by A. Prabhakar. The guide covers topics such as functions, data abstraction, and scoping, providing a comprehensive resource for students preparing for public examinations.

Uploaded by

gamertamilan627
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views193 pages

12CS_EM_2025

The document is a guide for computer science students, emphasizing simplicity and clarity in answers to help achieve full marks in examinations. It includes various chapters with questions and answers, QR codes for additional resources, and is authored by A. Prabhakar. The guide covers topics such as functions, data abstraction, and scoping, providing a comprehensive resource for students preparing for public examinations.

Uploaded by

gamertamilan627
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 193

என்றும் மாணவர்கள் நலனில்

COMPUTER SCIENCE

வாழ்த்துகளுடன்
அ. பிரபாகர்

VIJAY PUBLICATIONS Price Rs. 220

RASIPURAM
PREFACE
 It has been prepared keeping all students in mind with the primary motto
" - என்றும் மாணவர்கள் நலனில்".
 Simplicity and elegant answers have been effectively prepared by teachers with
more than 20 years of experience with a view to achieving full marks.
 Keeping in view the public examination answer keys, the answers, Python syntaxes,
examples with explanation and output are provided in a better understandable
manner.
 Following the book questions for each subject, all the questions asked from within
the chapter in the Public Examination and PTA questions are answered. Additional
questions have been given with emphasis on mandatory questions.
 A QR code is attached to the title of each lesson. With these, we can always answer
the quiz through our smart phone and know the marks obtained instantly.
 Through QR Codes in the guides, one can download the following full
pdf at anytime:

 (Minimum learning material)


 (set of model question papers and public exam papers)
 (set of questions not to be missed at the last moment)

 Best Wishes to Get Full Marks and a successful future.

- Author and Publisher


Contents

Chapter Title Page


இராசிபுரம் விஜய் பப்ளிகேஷன்ஸ்
Guide-ஆே
அச்சிட்டு வெளியிகிறது

93452 99522

ன் இதர வெளியீடுகள்
XI, XII கணினி அறிவியல் (TM & EM)
XI, XII கணினி பயன்பாடுகள் (TM & EM)
XI, XII வேலைோய்ப்புத் திறன்கள் (TM மட்டும்)
1 FUNCTION

Part - I
Choose the best answer: 1 Mark

(Sep 2021, Mar 2023)


a) Subroutines

(Jul 2022)
b) Function
(Mar 2022, PTA-6)
c) Definition
(Jun 2023, PTA-2)
d) Parameters
(Jul 2024)
a) Arguments

(PTA-4)
b) ()
(Mar 2024)
c) Interface

c) Implementation

(Mar 2020, PTA-3)

d) Pure functions

a) Impure function

Part - II
Answer the following questions: 2 Marks
1. What is a subroutine? (PTA-1)

..1.. A. PRABHAKAR-9442979144
– 1. FUNCTION
2. Define Function with respect to Programming language. (Sep 2021)

3. Write the inference you get from X:=(78).

4. Differentiate interface and implementation. (Jun 2023, PTA-3)


Interface Implementation

5. Which of the following is a normal function definition and which is recursive function
definition?
i) let sum x y: return x + y
ii) let disp:
print ‘welcome’
iii) let rec sum num:
if (num!=0) then return num + sum (num-1)
else
return num
Answers:

Part - III
Answer the following questions 3 Marks
1. Mention the characteristics of Interface. (Sep 2020, Mar 2023, Jul 2024)

2. Why strlen is called pure function?

3. What is the side effect of impure function. Give example.

..2.. A. PRABHAKAR-9442979144
– 1. FUNCTION
4. Differentiate pure and impure function. (Mar 2020, Mar 2024, PTA-6)
Pure Function Impure Function

5. What happens if you modify a variable outside the function? Give an example.

Part - IV
Answer the following questions 5 Marks
1. What are called Parameters and write a note on (May 2022, Jul 2024, PTA-2)
(i) Parameter without Type (ii) Parameter with Type
Parameter:

(i) Parameter without Type:

..3.. A. PRABHAKAR-9442979144
– 1. FUNCTION

(ii) Parameter with Type:

2. Identify in the following program (PTA-5)


let rec gcd a b :=
if b <> 0 then gcd b (a mod b) else return a
i) Name of the function
ii) Identify the statement which tells it is a recursive function
iii) Name of the argument variable
iv) Statement which invoke the function recursively
v) Statement which terminates the recursion
Answers:

3. Explain with example Pure and impure functions.


Pure function:


Example:

..4.. A. PRABHAKAR-9442979144
– 1. FUNCTION
Impure function: (PTA-5)

4. Explain with an example interface and implementation.


Interface:

.
Implementation:

ENGINE

getSpeed

No
Requir
ed Pull Fuel

Yes
Return


..5.. A. PRABHAKAR-9442979144
– 1. FUNCTION

(Sep 2020)
c) Subroutine
(PTA-1)

d) recursive function
ADDITIONAL QUESTIONS

c) let

a) rec

a) static

b) Pure functions

b) c) random() d)

c) Objects
7. What are parameters and arguments?


8. What is recursive function?

9. `How will you solve the problem of chameleons in chrome land? Describe by
algorithm and flowchart?

..6.. A. PRABHAKAR-9442979144
– 1. FUNCTION

--inputs:
--outputs:
Example:

iteration a b c
0 4 4 6
1 3 3 8
2 2 2 10
3 1 1 12
4 0 0 14
Algorithm:

Flowchart:

..7.. A. PRABHAKAR-9442979144
2 DATA ABSTRACTION

Part - I
Choose the best answer: 1 Mark

(Sep 2020, Sep 2021, Jul 2022)


a) Constructors
(May 22)
b) Selectors

b) List
(Mar 2020, Jun 2023, Jul 2024)
c) Tuple
(Mar 2023, PTA-2)

c) Concrete datatype
(Mar 2024)

d) Abstract datatype

a) Pair
(PTA-4)
a) Pair

c) Classes

b) Lists
Part - II
Answer the following questions: 2 Marks
1. What is abstract data type? (Sep 2021, May 2022, Mar 2024)

2. Differentiate constructors and selectors. (Jul 2022, Jul 2024, PTA-2, PTA-3)


3. What is a Pair? Give an example. (Mar 2020, Jun 2023)

..8.. A. PRABHAKAR-9442979144
– 2. DATA ABSTRACTION

Example:
4. What is a List? Give an example.

Example:
5. What is a Tuple? Give an example. (Mar 2023)

Example:
Part - III
Answer the following questions: 3 Marks
1. Differentiate Concrete data type and abstract datatype.
Concrete data type Abstract datatype

2. Which strategy is used for program designing? Define that Strategy.



3. Identify Which of the following are constructors and selectors? (PTA-5)


a) N1=number( )
b) accetnum(n1)
c) displaynum(n1)
d) eval(a/b)
(e) x,y= makeslope (m), makeslope(n)
(f) display( )
4. What are the different ways to access the elements of a list. Give example.

1] Multiple assignment:

Example:

..9.. A. PRABHAKAR-9442979144
– 2. DATA ABSTRACTION
2] Element selection operator:

Example:

5. Identify Which of the following are List, Tuple and class?


a) arr [1, 2, 34]
b) arr (1, 2, 34)
c) student [rno, name, mark]
d) day= (‘sun’, ‘mon’, ‘tue’, ‘wed’)
(e) x= [2, 5, 6.5, [5, 6], 8.2]
(f) employee [eno, ename, esal, eaddress]
Part - IV
Answer the following questions: 5 Marks
1. How will you facilitate data abstraction. Explain it with suitable example.
(Jun 2023, Mar 2024, PTA-2, PTA-4)


2. What is a List? Why List can be called as Pairs? Explain with suitable example.
(Mar 2023, PTA-6)

..10.. A. PRABHAKAR-9442979144
– 2. DATA ABSTRACTION
Example:

3. How will you access the multi-item. Explain with example.

(PTA-1)
)
) d) Abstract Data Type
2. (PTA-5)

c) either A or B

(PTA-6)

4. a) What is a selector? b) What are the parts of a program? (Sep 2020)


a) Selector

b) Parts of a program

..11.. A. PRABHAKAR-9442979144
– 2. DATA ABSTRACTION

a) Abstraction

d) Modularity

b) Classes

a) Pairs

b) 2

)
c) Concrete Data Type )

b) 2

b) [ ] c) )

a) ( ) ) ) )

b) Wishful thinking

d) Comma(,)

c) i, iii Only

a) Class
14. What is abstraction?

15. Explain the representation of Abstract datatype using Rational numbers.


..12.. A. PRABHAKAR-9442979144
– 2. DATA ABSTRACTION

Example:

Example: An ADT for rational numbers



The pseudo code for the representation of the rational number using the above
constructor and selector is

..13.. A. PRABHAKAR-9442979144
3 SCOPING

Part - I
Choose the best answer: 1 Mark

a) Scope
(Sep 2020, Sep 2021)
b) Mapping

(PTA-2)
c) =
(May 2022)

d) Namespaces
(Jul 2022)
a) Local Scope

b) Modular programming

(Mar 2024)

c) Access control

(Mar 2020, Jul 2024)

d) Private members
(Mar 2023)
a) Public members

(PTA-6)
b) Protected members

..14.. A. PRABHAKAR-9442979144
– 3. SCOPING
Part - II
Answer the following questions: 2 Marks
1. What is a scope? (Mar 2023)

2. Why scope should be used for variable. State the reason.


3. What is Mapping? (May 2022, PTA-5)

4. What do you mean by Namespaces? (Mar 2020, Jul 2022, Jul 2024, PTA-4)

5. How Python represents the private and protected Access specifiers?



Part - III
Answer the following questions: 3 Marks
1. Define Local scope with an example. (Sep 2021)

Example: Output:

→ local scope

2. Define Global scope with an example. (Jul 2024, PTA-6)


..15.. A. PRABHAKAR-9442979144
– 3. SCOPING
Example: Output:
→ global scope

→ local scope

3. Define Enclosed scope with an example. (PTA-3)



Example: Output:

→ enclosed scope

4. Why access control is required? (PTA-1)

5. Identify the scope of the variables in the following pseudo code and write its output.
color:= Red
mycolor():
b:=Blue
myfavcolor():
g:=Green
print color, b, g
myfavcolor()
print color, b
mycolor()
print color
Scope of variables: Output:
→ global scope
→ enclosed scope
→ local scope

..16.. A. PRABHAKAR-9442979144
– 3. SCOPING
Part - IV
Answer the following questions: 5 Marks
1. Explain the types of scopes for variable or LEGB rule with example.
(Sep 2020, Sep 2021, May 2022, Mar 2024, PTA-1)

Local scope:


.
Enclosed scope:

Global scope:

Built-in scope:

..17.. A. PRABHAKAR-9442979144
– 3. SCOPING
Example:
→ library files
→ global scope

→ enclosed scope

→ local scope

Output:

2. Write any Five Characteristics of Modules. (Sep 2020, Jun 2023, Jul 2024, PTA 4, PTA 6)
1.
2.
3.
4.
5.
3. Write any five benefits in using modular programming.




(PTA-1)
c) Enclosed
(PTA-3)
a) Built-in scope variables

..18.. A. PRABHAKAR-9442979144
– 3. SCOPING
(PTA-5)
c) class
Define module. (PTA-4)


c) life time

d) all of these

c) Programs

a) Access control

a) Local

d) Built-in

a) local scope

c) Modules

d) Modules

a) private

b) public

a) Data Encapsulation

c) protected

c) Single or Double underscore

..19.. A. PRABHAKAR-9442979144
– 3. SCOPING

b) public

a) private
What is the lifetime of a variable?

What is modular programming?

What is nested function?

Write about the access specifiers.


..20.. A. PRABHAKAR-9442979144
4 ALGORITHMIC STRATEGIES

Part - I
Choose the best answer: 1 Mark

(Sep 2021, May 2022, PTA-6)


c) Algorithm

d) Selection sort
(Mar 2020, Jun 2023)

c) Time and space

a) Algorithmic solution

(Mar 2024)
d) Big O

a) Big O 

d) Half-interval search
Θ
b) Average case

a) Overlapping subproblems

(Mar 2023, Jul 2024)

c) Memoization
Part - II
Answer the following questions: 2 Marks
1. What is an Algorithm? (Mar 2020, Sep 2021)

..21.. A. PRABHAKAR-9442979144
– 4. ALGORITHMIC STRATEGIES
2. Write the phase of the performance evaluation of an algorithm. (PTA-5)

3. What is Insertion sort?

4. What is Sorting?

Example:
❖ ❖ ❖
5. What is searching? Write its types. (May 2022, Mar 2024)

Part - III
Answer the following questions: 3 Marks
1. List the characteristics of an algorithm. (Sep 2021, May 2022)

2. Discuss about Algorithmic complexity and its types.

➢ Time Complexity:

➢ Space Complexity:

3. What are the factors that influence time and space complexity.
[ / What are the factors that measure the execution time of an algorithm? (PTA-6) ]

(PTA-6)

..22.. A. PRABHAKAR-9442979144
– 4. ALGORITHMIC STRATEGIES



4. Write a note on Asymptotic notation. (Mar 2020, Jun 2023, Mar 2024)



→
5. What do you understand by Dynamic programming? (Sep 2020, Mar 2023)

Steps to do Dynamic programming:




Part - IV
Answer the following questions: 5 Marks
1. Explain the characteristics of an algorithm. (PTA-5)
❖ Input:
❖ Output:
❖ Finiteness:
❖ Definiteness:

❖ Effectiveness:
❖ Correctness:
❖ Simplicity:
❖ Unambiguous:

❖ Feasibility:
❖ Portable:

❖ Independent:

..23.. A. PRABHAKAR-9442979144
– 4. ALGORITHMIC STRATEGIES
2. Discuss about Linear search algorithm. (Mar 2020, Jul 2022, Mar 2023, PTA-1)

Pseudo code:


3. What is Binary search? Discuss with example. (Sep 2021, Jun 2023, Mar 2024)


Pseudo code for Binary search


..24.. A. PRABHAKAR-9442979144
– 4. ALGORITHMIC STRATEGIES
For example:

❖ 50 60.
1

❖ mid
high to mid - 1


4. Explain the Bubble sort algorithm with example. (May 2022, PTA-6)

..25.. A. PRABHAKAR-9442979144
– 4. ALGORITHMIC STRATEGIES

5. Explain the concept of Dynamic programming with suitable example. (Jul 2024)

Steps to do Dynamic programming




Fibonacci Series – An example

..26.. A. PRABHAKAR-9442979144
– 4. ALGORITHMIC STRATEGIES
Fibonacci Iterative Algorithm with Dynamic programming approach
Step - 1:
Step - 2:
Step - 3:
Step - 4:
Step - 5: Step - 2

(SEP 2020)

d) Selection
(PTA-5)
d) Binary search
(PTA-1)
a) O(n) θ θ θ
(PTA-2)
d) Algorithm
(PTA-3)
b) Program
(PTA-4)

Write a short note on the factors of measuring complexity of an algorithm. (PTA-2)


Write a pseudo code for bubble sort algorithm. (PTA-3)


BubbleSort(array):
n = length(array)
for i from 0 to n-1:
swapped = false
for j from 0 to n-i-2:
if array[j] > array[j+1]:
swap(array[j], array[j+1])
swapped = true

..27.. A. PRABHAKAR-9442979144
– 4. ALGORITHMIC STRATEGIES
if swapped == false:
break
Write the pseudo code for linear search. (PTA-4)
LinearSearch(array, target):
n = length(array)
for i from 0 to n-1:
if array[i] == target:
return i // element found at the index position
return -1 // element not found
Write the pseudo code for selection sort algorithm. (PTA-4)
SelectionSort(array):
n = length(array)
for i from 0 to n-1:
min_index = i
for j from i+1 to n-1:
if array[j] < array[min_index]:
min_index = j
if min_index != i:
swap(array[i], array[min_index])

b) Algorithm

d) Algorithmic strategy

c) Algorithmic solution

a) Average case

b) Best case

d) Sequential search

b) Binary search

..28.. A. PRABHAKAR-9442979144
– 4. ALGORITHMIC STRATEGIES
8. What is an algorithmic solution?

9. What is analysis if algorithm?

10. What is algorithmic strategy?

11. What is time complexity?

12. What is space complexity?

13. What do you mean by best algorithm?

14. What is memoization?

15. Differentiate between algorithm and program.

..29.. A. PRABHAKAR-9442979144
5 PYTHON – VARIABLES AND OPERATORS

Part - I
Choose the best answer: 1 Mark
(Jul 2024)
b) Guido Van Rossum

a) >>>
(Jul 22, Jun 23)
d) Ctrl + N

(Sep 2021, PTA-6)


a) #
(Jul 2022)
c) comma (,)

a) Interpreter
(Mar 2023)
d) operators
(May 2022, PTA-1)
b) Relational

d) Assignment

a) Ternary
Part - II
Answer the following questions: 2 Marks
1. What are the different modes that can be used to test Python Program? (Sep 21, May 22)

2. Write short notes on Tokens. (Sep 2020, Jun 2023, PTA-3, PTA-4)

..30.. A. PRABHAKAR-9442979144
– 5. VARIABLES AND OPERATORS
3. What are the different operators that can be used in Python? (Mar 2024, PTA-5, PTA-6)
❖ ❖
❖ ❖

4. What is a literal? Explain the types of literals? (Jul 2024)

5. Write short notes on Exponent data?

Part - III
Answer the following questions: 3 Marks
1. Write short notes on Arithmetic operator with examples. (Sep 2021, May 2022)

Operator (Operation) Examples Result


110
90
1000
3.3333
1
100
3
2. What are the assignment operators that can be used in Python?

Assignment Operators:

Example:

3. Explain Ternary operator with examples. (Mar 2020, Mar 2023, PTA-1)

..31.. A. PRABHAKAR-9442979144
– 5. VARIABLES AND OPERATORS

Syntax:

Example:

4. Write short notes on Escape sequences with examples. (Jul 2024)


Escape sequence Description Example Output


character

5. What are string literals? Explain. (Jun 2023)




Example:

Part - IV
Answer the following questions: 5 Marks
1. Describe in detail the procedure Script mode programming.

..32.. A. PRABHAKAR-9442979144
– 5. VARIABLES AND OPERATORS
Creating and Saving Scripts in Python

Executing Python Script


2. Explain input() and print() functions with examples. (Mar 2020, May 2022, Jun 2023,
Mar 2024, PTA-3)
input( ) function:

The syntax is

Example:



Example:

print() function:

..33.. A. PRABHAKAR-9442979144
– 5. VARIABLES AND OPERATORS
The syntax is

1” 2”’ 2)
Example:



3. Discuss in detail about Tokens in Python. (Sep 2021, Mar 2023, Jul 2024, PTA-3)
Tokens:

1) Identifiers:




Example :
2) Keywords:

..34.. A. PRABHAKAR-9442979144
– 5. VARIABLES AND OPERATORS
3) Operators:




Example : +, -, *, /, <, <=, …
4) Delimiters:

5) Literals:

(Mar 2020)

c) Integrated Development Learning Environment

(Sep 2021)
b) #
(Sep 2020, Mar 2024)
b) F5
(PTA-2)

a) 3

..35.. A. PRABHAKAR-9442979144
– 5. VARIABLES AND OPERATORS
(PTA-3)
b) 2
(PTA-4)

c) Statement (3) Only


(PTA-5)
d) //
Explain data types in Python. (Sep 2020)

(1) Number Data type:



Example:

(2) Boolean Data type:

Example :

(3) String Data type:

Example :

..36.. A. PRABHAKAR-9442979144
– 5. VARIABLES AND OPERATORS
List the key features of Python. (PTA-3)



What are keywords? List some keywords. (PTA-1)

Explain the different types of operators used in Python. (Jul 2022, PTA-1)
Arithmetic operators:

Operator (Operation) Examples Result


110
90
1000
3.3333
1
100
3
Relational or Comparative operators:

Operator (Operation) Examples Result


True
True
False
True
False
True

..37.. A. PRABHAKAR-9442979144
– 5. VARIABLES AND OPERATORS
Logical operators:


➢ and, or not
Example:



Assignment operators:

Assignment Operators:

Example:



Conditional Operator:

Syntax:

Example:

c) Netherland

b) 1991

) b) object ) )

..38.. A. PRABHAKAR-9442979144
– 5. VARIABLES AND OPERATORS

d) .py

a) Run → Run Module →


→ →

b) strings

a) int()

c) Both a) and b)

a) Whitespace

a) 12Name

b) ==

a) =

c) 505

b) 10

b) 0o

b) 10.0

c) “Python”

..39.. A. PRABHAKAR-9442979144
– 5. VARIABLES AND OPERATORS

d) The Sum is : 30

d) 3

a) True

a) True

a) 20

c) 3.14
What is an Interactive mode Programming?

Write a note on comments in Python?

..40.. A. PRABHAKAR-9442979144
– 5. VARIABLES AND OPERATORS
Example:

What are operators and operands?



What are delimiters?

What is identifier? Write the rules using identifiers. Give example






Example of valid identifiers:

Example of invalid identifiers:

..41.. A. PRABHAKAR-9442979144
6 CONTROL STRUCTURES

Part - I
Choose the best answer: 1 Mark
(Mar 2023)
a) 3
(May 2022, Jun 2023)
c) else if
(Sep 2021)
d) Indentation
(Jul 2024)
c) pass

c) Relational or Logical expression

c) for

a) 12

b) True
(PTA-2, PTA-6)
a) for

b) :

..42.. A. PRABHAKAR-9442979144
– 6. CONTROL STRUCTURES
Part - II
Answer the following questions: 2 Marks
1. List the control structures in Python. (Jun 2023, PTA-6)

2. Write note on break statement. (Sep 2021, Jul 2024)



Syntax:

3. Write is the syntax of if .. else statement.

4. Define control structure. (PTA-2)

5. Write note on range () in loop. (Mar 2020, Jul 2022, Mar 2023)

The syntax is

Example:


Part - III
Answer the following questions: 3 Marks
1. Write a program to display (Mar 2022, PTA-5)
A
AB
ABC
ABCD
ABCDE
..43.. A. PRABHAKAR-9442979144
– 6. CONTROL STRUCTURES
Program:

2. Write note on if .. else structure.

Syntax:

Example:

Output:

3. Using if.. elif.. else statement, write a suitable program to display largest of 3
numbers. (Mar 2024)

..44.. A. PRABHAKAR-9442979144
– 6. CONTROL STRUCTURES
4. Write the syntax of while loop. (Jul 2022, Mar 2023, Jul 2024, PTA-2, PTA-4)

5. List the differences between break and continue statements. (Mar 2022)

Part - IV
Answer the following questions: 5 Marks
1. Write a detail note on for loop. (Sep 2021, May 2022, Jul 2022, Jul 2024)

Syntax:

Example:

Output:

..45.. A. PRABHAKAR-9442979144
– 6. CONTROL STRUCTURES

Output:

2. Write a detail note on if.. elif.. else statement with suitable example. (PTA-3) /
Write the syntax of Nested if..elif...else statement with example. (Sep 2020)

Syntax:

Example:

Output:

..46.. A. PRABHAKAR-9442979144
– 6. CONTROL STRUCTURES
3. Write a program to display all 3-digit odd numbers. (Mar 2020)

4. Write a program to display multiplication table for a given number.

(Mar 2020)

c) 2 4 6 8

(Sep 2020)
b) continue
(Jul 2022)
c) for
(Mar 2024)

a) 0 1 3 4
(PTA-1)

a) 1 3 5 7 9
(PTA-3)

c) 000000
16. (PTA-5)
c) step

..47.. A. PRABHAKAR-9442979144
– 6. CONTROL STRUCTURES
(PTA-4)

Write the output for the following Python programs. (Sep 2020)

Output:

Output:

(i) Write a program to display all 3 digit even numbers. (Mar 2020)
(ii) Write the output for the following program.
i=1
while(i<=6):
for j in range(1, i):
print(j,end="\t)
print(end="\n)
i+=1

..48.. A. PRABHAKAR-9442979144
– 6. CONTROL STRUCTURES
(i)

(ii) Output:

Draw a flow chart to explain while loop. (PTA-2)

Explain the Jump Statements in Python. (PTA-1, PTA-6)



break:


Syntax:

Example: Output:

..49.. A. PRABHAKAR-9442979144
– 6. CONTROL STRUCTURES
continue:

Syntax:
continue
Example: Output:

pass:



Syntax:

Example: Output:

Explain while loop with example. (PTA-4)


while

Syntax:
while <condition>:
statements block 1
[else:
statements block2]
statements block1 else

Example:

..50.. A. PRABHAKAR-9442979144
– 6. CONTROL STRUCTURES
Output:

) Control statements

d) while

a) break

c) pass

c) pass

c) 10 12 14

d) 29

a) 0

a) 10 11 12 13 14 15 16

..51.. A. PRABHAKAR-9442979144
– 6. CONTROL STRUCTURES

b) 2 4 6 8

c) Comput

a) Computr Scinc

d) 1 2 3 4
14. What is Sequential Statement? Give Example.

Example:

15. What is alternative or branching statement.

..52.. A. PRABHAKAR-9442979144
– 6. CONTROL STRUCTURES
16. Write short note on simple if statement.

Syntax:
if <condition>:
statements-block1
Example: Output:

17. What is Looping? Write its types.



18. What is Nested loop structure?

19. What is the use of end and sep parameters in print() function?
➢ end

➢ sep

20. Write the importance of indentation in python.

..53.. A. PRABHAKAR-9442979144
7 PYTHON FUNCTIONS

Part - I
Choose the best answer: 1 Mark

c) Function
(Mar 2023)
b) Recursion
(May 2022, Jul 2023, Jul 2024,
PTA-1)
a) Lambda
(Sep 2020)
d) def
(Sep 2021, Jul 2022)
b) return

c) : (colon)

a) Required

a) I is correct and II is wrong

(Mar 2024)

b) x%4==0
(PTA-3)
c) def
Part - II
Answer the following questions: 2 Marks
1. What is function?

2. Write the different types of function. (Sep 2021, Mar 2024)

..54.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS
3. What are the main advantages of function? (Sep 2020, Jun 2023)


4. What is meant by scope of variable? Mention its types. (Jul 2022)

5. Define global scope.




6. What is base condition in recursive function? (PTA-6)

7. How to set the limit for recursive function? Give an example. (PTA-5)

Part - III
Answer the following questions: 3 Marks
1. Write the rules of local variable. (Mar 2022)




2. Write the basic rules for global keyword in python. (Jul 2022, Jul 2024, PTA-4)



3. What happens when we modify global variable inside the function?
❖ “Unbound Local
Error

..55.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS
4. Differentiate ceil() and floor() function? (Mar 2023, PTA-2)
floor(x) ceil (x)

Example: Example:
→ →
5. Write a Python code to check whether a given year is leap year or not. (Jun 2023)

6. What is composition in functions? (Jun 2023)

composition
Example :

7. How recursive function works?

8. What are the points to be noted while defining a function?


❖ “def”


❖ “return [expression]”

..56.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS
Part - IV
Answer the following questions: 5 Marks
1. Explain the different types of function with an example. (Jul 2022, PTA-3)
1) User-defined Functions:

Syntax:

Example: Output:

2) Built-in Functions:


3) Lambda or Anonymous Functions: (PTA-2)

➢ def
lambda
lambda
Syntax:
lambda [argument(s)] : expression
Example: Output:

✓ arg1 arg2

4) Recursion Functions:

Example: Output:

..57.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS

2. Explain the scope of variables with an example. (Sep 2021, Jun 2023, Mar 2024, PTA-3)


Local Scope:

Rules of local variable





Example:

Output:

Global Scope:

Rules of global Keyword




Example:
→ global variable

Output:

..58.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS
3. Explain the following built-in functions. (Mar 2020, Mar 2023, PTA-4, PTA-6)
a) id() b) chr() c) round() d) type() e) pow()
a) id() :

Syntax:

Example: Output:

b) chr() :

Syntax:

Example: Output:

c) round()

Syntax:

Example: Output:

d) type() :

Syntax:

Example: Output:

(e) pow() :

Syntax:

..59.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS
Example: Output:

4. Write a Python code to find the L.C.M. of two numbers.


Program: Output:

5. Explain recursive function with an example. (Mar 2020, Jul 2024, PTA-5)

Overview of how recursive function works

Example: Output:

..60.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS
Example:

(Mar 2020)

b) 14
(PTA-2)
b) 
(PTA-4)
c) Tuples
(PTA-5)

d) Error
(PTA-6)

d) Fixed length arguments


Write notes on: (i) MAX () function (ii) MIN () function (Jun 2023)
(i) max():

(ii) min():

..61.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS

Debug the following Python program to get the given output : (Sep 2020)
Output: Correct Program:

Program:

Write the syntax of creating User Defined Function in Python. (PTA-1)

What is the use of lambda function? (PTA-2)


List the different types of arguments and explain with suitable examples. (PTA-4)

1. Required Arguments:
➢ Required Arguments

..62.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS
Example:
def

2. Keyword Arguments:

Example:

3. Default Arguments:

Example:

..63.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS

4. Variable-Length Arguments:


Example:

a) Function

d) 4

d) 4

d) return

a) Parameters

b) Arguments

a) Keyword arguments

..64.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS

c) Default argument

a) Keyword arguments

d) Error

c) None

a) hello – Python
None

d) Error

a) 30

..65.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS

d) 60
20

d) Error

a) 1000

c) lambda

b) global

c) 5
5

b) -18

c) 30

..66.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS

d) 10
5
24. What is a block?

25. What is nested block?

26. What are the advantages of user defined functions?


27. What are parameters and arguments?




28. Explain the return statement in detail.

Syntax:
return [expression list]

..67.. A. PRABHAKAR-9442979144
– 7. PYTHON FUNCTIONS

Example:

Output 1: Output 2:

..68.. A. PRABHAKAR-9442979144
8 STRINGS AND STRING MANIPULATION

Part - I
Choose the best answer: 1 Mark

d) udaNlimaT
(May 2022)

c) Type error
(Mar 2023, Jul 2024)
a) +

b) Multiline Strings

(Sep 2021)
c) Immutable
(Mar 2024, PTA-1)
b) [ ]
(Jul 2022, PTA-2)

d) third argument of slice operation

(PTA-5)
b) %E

(Jun 2023, PTA-4)


a) { }

d) either a) or b)
Part - II
Answer the following questions: 2 Marks
1. What is String? (Sep 2021, Jul 2024)

..69.. A. PRABHAKAR-9442979144
– 8. STRINGS AND STRING MANIPULATION
Example:
(i) (ii) (iii)
2. Do you modify a string in Python?

3. How will you delete a string in Python? (Mar 2023)

del
Example:

4. What will be the output of the following python code? (Jul 2022, PTA-1)

Output:

5. What is slicing? (Sep 2021, PTA-3)

Part - III
Answer the following questions: 3 Marks
1. Write a Python program to display the given pattern. (Mar 2023)
Program:
str="COMPUTER"
i = len(str)
while (i > 0):
print(str[:i])

2. Write a short about the followings with suitable example:


a) capitalize( ) b) swapcase( ) (Sep 2020, Mar 2024, PTA-1, PTA-3)
a) capitalize( ):

Example:

Tamilnadu

..70.. A. PRABHAKAR-9442979144
– 8. STRINGS AND STRING MANIPULATION
b) swapcase( )

Example:

TAMIL nadu
3. What will be the output of the given python program?

Output:

4. What is the use of format()? Give an example.


Example:


Output:

5. Write a note about count() function in python.


Syntax:

Example:

..71.. A. PRABHAKAR-9442979144
– 8. STRINGS AND STRING MANIPULATION
Part - IV
Answer the following questions: 5 Marks
1. Explain about string operators in python with suitable example. (Jun 2023, Jul 2024,
PTA-2)
(i) Concatenation (+):

Example:

welcome to Python
(ii) Append (+=):

Example:

Welcome to Learn Python


(iii) Repeating ():

Example:


Welcome Welcome Welcome Welcome
(iv) String slicing:

Syntax:
str[start:end]
✓ start end

Example:

T
..72.. A. PRABHAKAR-9442979144
– 8. STRINGS AND STRING MANIPULATION

THIRU
(v) Stride when slicing string: (PTA-6)

Example:

learn

er

(Mar 2020)

Answer : Error
(Sep 2020)
c) *
(PTA-3)
c) del
(PTA-6)

d) CMUE
What will be the output of the given Python program? (Mar 2020)
str="COMPUTER SCIENCE”
a) print(str*2)
b) print(str[0 : 7])

Write short note on replace() function. (Sep 2020)


..73.. A. PRABHAKAR-9442979144
– 8. STRINGS AND STRING MANIPULATION
Syntax:
replace(“char1”, “char2”)

Example:

Hew are yeu


What is output for the following Python program? (Sep 2020)
a = "Computer"
b = "Science"
x = a[:4] + b[len(b)-3:]
print(x)
Output:

Explain the following built-in string functions. (Sep 2020, PTA-5)


a) isalpha() b) isdigit() c) islower() d) isupper() e) title()

isalpha()

isdigit()

islower()

isupper()

title()

What is output for the following Python Commands? (Sep 2021)


str = “Thinking with Python”
(i) print(str[::3]) (ii) print(str[::—3]) (iii) print(str[9:13])

..74.. A. PRABHAKAR-9442979144
– 8. STRINGS AND STRING MANIPULATION
Write the output for the following Python commands: (Mar 2020)
str1="Welcome to Python"
(i) print(str1) (ii) print(str1[11 : 17]) (iii) print(str1[11 : 17 : 2])
(iv) print(str1[: : 4]) (v) print(str1[: : —4])

What is the use of string formatting operators? (PTA-6)

Syntax:

Example:

Output:

What is the use of membership operators? (PTA-2)


in not in

Example: Output 1:

Output 2:

What is swapcase()? Write with an example. (PTA-3)

Example:

Output:

..75.. A. PRABHAKAR-9442979144
– 8. STRINGS AND STRING MANIPULATION
What will be output of the following Python snippet? (PTA-4)
Output:

What will be the output of the following Python program? (PTA-4)

Output:

What is the use of find() function? Give an example. (PTA-4, PTA-5)




Syntax:

Example:
=
)
output:

What is the positive and negative subscript value of the character 'h' in string 'school'?
(PTA-5)



How index value allocated to each character of a string in Python? (PTA-5)
/ How will you access characters in a string?

..76.. A. PRABHAKAR-9442979144
– 8. STRINGS AND STRING MANIPULATION

Example:

Write the general format of slicing operation? (PTA-6)

Write a note on string formatting operators of Python. (PTA-6)

Syntax:

Example:

Output:

c) String

d) Subscript

a) 0

a) 0 c) -1

b) +=

a) %

a) len(str)

a) count()

..77.. A. PRABHAKAR-9442979144
– 8. STRINGS AND STRING MANIPULATION

c) replace()

c) h

b) o

b) Compu

str=”Cat”
str[0]=”B”
print(str)
d) Error

c) third

a) o b) otPnalo mce c) nhy re teolW d) e

str1=”Welcome”
print(str1.center(15,’*’))

c) ****Welcome****
17. What is the use of len() function? Give an example.

Example:

..78.. A. PRABHAKAR-9442979144
– 8. STRINGS AND STRING MANIPULATION
18. Compare ord( ) and chr() functions.
ord(char ) chr(ASCII)
• •

• Example: • Example:

65
19. Write short note on escape sequences in Python.


Escape Sequence Description

..79.. A. PRABHAKAR-9442979144
9 LISTS, TUPLES, SETS AND DICTIONARY

Part - I
Choose the best answer: 1 Mark
(Jun 2023)
d) Loop

b) 8

c) len()
(Mar 2024)

c) [10,20,35,40,50]
(May 2022, PTA-1)
b) [17,23,41,10,32]

c) extend()
(Jul 2022)

b) [0,1,4,9,16]
(Jul 2024)

c) To know the data type of python object.

d) The extend() function is used in tuple to add elements in a list.

(Mar 2023, PTA-2)

d) {1,3,6,9}

..80.. A. PRABHAKAR-9442979144
– 9. LISTS, TUPLES, SETS AND DICTIONARY

a) Symmetric difference

(Mar 2020)
d) :
Part - II
Answer the following questions: 2 Marks
1. What is List in Python? (Sep 2021)
“sequence data type”

2. How will you access the list elements in reverse order?

Example: Output:

3. What will be the value of x in following python code?

The value of x is 4
4. Differentiate del with remove() function of List.


Example:

or
5. Write the syntax of creating a Tuple with n number of elements. (Mar 2022)

..81.. A. PRABHAKAR-9442979144
– 9. LISTS, TUPLES, SETS AND DICTIONARY
6. What is set in Python? (Jul 2022, Jun 2023, PTA-4)

Part - III
Answer the following questions: 3 Marks
1. What are the difference between list and of Tuples ot?
List Tuples

2. Write a short note about sort( ). (Jul 2024)

Syntax:



Example: Output:

3. What will be the output of the following code? (Mar 2020)




Output:

4. Explain the difference between del and clear() in dictionary with an example.



Example: Output:

del Dict['Mark1']
NameError: name 'Dict' is not defined

..82.. A. PRABHAKAR-9442979144
– 9. LISTS, TUPLES, SETS AND DICTIONARY
Dict.clear()

del Dict

5. List out the set operations supported by python. (Mar 2020)

6. What are the differences between List and Dictionary? (Jun 2023, PTA-3)
List Dictionary

Part - IV
Answer the following questions: 5 Marks
1. What the different ways to insert an element in a list. Explain with suitable example.
(Jun 2023)

(i) append():

Syntax:
List.append(element to be added)
Example:

..83.. A. PRABHAKAR-9442979144
– 9. LISTS, TUPLES, SETS AND DICTIONARY
(ii) extend():

Syntax:
List.extend([elements to be added])
Example:

(iii) insert():

Syntax:
List.insert (position index, element)
Example:

[10, 23, 60, 41, 75]


2. What is the purpose of range( )? Explain with an example. (Sep 2021, Jul 2022, Mar 2024,
PTA-2)

i. Syntax:

✓ start value
✓ end value
✓ step value
Example: Output:

ii. Creating a list with range() function:



..84.. A. PRABHAKAR-9442979144
– 9. LISTS, TUPLES, SETS AND DICTIONARY
Syntax:

Example:

3. What is nested tuple? Explain with an example. (Jul 2022, Mar 2023)



Example:

Output:

4. Explain the different set operations supported by python with suitable example.
(Mar 2020, Sep 2020, May 2022, Jul 2024, PTA-1)

(i) Union:

➢ | union( )

Example: Output:

(OR)
(ii) Intersection:

➢ & intersection( )

..85.. A. PRABHAKAR-9442979144
– 9. LISTS, TUPLES, SETS AND DICTIONARY
Example: Output:

(OR)
(iii) Difference:

➢ (-) difference( )

Example: Output:

(OR)
(iv) Symmetric difference: (PTA-3)

➢ (^) symmetric_difference()

Example: Output:

(OR)

(SEP 2020)

d) 80
(Sep 2021)

b) 23
(SEP 2021)
d) 8
(PTA-3)
c) len()
(PTA-4)
b) range()

..86.. A. PRABHAKAR-9442979144
– 9. LISTS, TUPLES, SETS AND DICTIONARY

(PTA-5)
c) Set
(PTA-6)

c) 5
How will you create a list in python? (Sep 2020)

Syntax:

Example:

Write the use of POP() function in Python. (Mar 2024)



Write execution table for the following Python code. (PTA-1)

Execution table

Write the syntax of Dictionary creation. (PTA-1)

What will be the output of the following snippet? (PTA-2)

..87.. A. PRABHAKAR-9442979144
– 9. LISTS, TUPLES, SETS AND DICTIONARY
Output:

What will be the output of the following Python program? (PTA-2, PTA-5)

Output:

What will be the output of the following snippet? (PTA-3)

Output:

What will be the output of the following Python program? (PTA-4)

Output:

What will be the output of the following snippet? (PTA-5)

Output:

What are the collection data types available in Python? (PTA-6)

..88.. A. PRABHAKAR-9442979144
– 9. LISTS, TUPLES, SETS AND DICTIONARY
Write a simple python program with list of five marks and print the sum of all the
marks using while loop. (PTA-5)
Output:

Consider the following tuple declaration: (PTA-6)

What will be the output of the following print statements?


(i) >>>print(Mytuple[2:3]) (ii) >>>print(Mytuple[3:]) (iii) >>>print(Mytuple[:])

“sequence data type”


d) String

c) List

a) Tuples

d) Dictionary

d) All are correct

d) Set

c) 5

..89.. A. PRABHAKAR-9442979144
– 9. LISTS, TUPLES, SETS AND DICTIONARY

b) [2,4,6,8,10]

c) [1,4,9,16,25,36,49,64,81,100]

print(x)
b) 1

c) Dictionary

c) Error

b) {1:2,2:4,3:6}

) -2

b) 3

b) type()

a) tup=(10,)

b) clear()
19. Write short note on List comprehension.

..90.. A. PRABHAKAR-9442979144
– 9. LISTS, TUPLES, SETS AND DICTIONARY
Syntax:

Example:

Output:

20. How can you access the list elements?


Example:

21. How can you access all the list elements using for loop?

Syntax:


Example: Output:

22. What is Singleton tuple?

Example:

23. How can you create tuples using tuple( ) function?



Syntax:

..91.. A. PRABHAKAR-9442979144
– 9. LISTS, TUPLES, SETS AND DICTIONARY
Example: Output:

24. What is meant by tuple assignment?

Example:

25. What is Dictionary?



26. Write the output of this statement.

..92.. A. PRABHAKAR-9442979144
10 PYTHON CLASSES AND OBJECTS

Part - I
Choose the best answer: 1 Mark

c) Classes and Objects


(PTA-4)
c) Methods
(Mar 2020, Jul 2022, Mar 2023)

d) __init__( )
(Jul 2024)
a) __
(May 2022, PTA-1)
d) __del__( )
(Sep 2021, PTA-6)

c) class class_name:

b) Tamil
(PTA-2)
a) __num
(Sep 2021, Jun 2023, Mar 2024)

d) Instantiation
Part - II
Answer the following questions: 2 Marks
1. What is class? (Mar 2023, Jul 2024, PTA-1)

..93.. A. PRABHAKAR-9442979144
– 10. PYTHON CLASSES AND OBJECTS
2. What is instantiation? (PTA-6)

3. What is the output of the following program?

Output:

4. How will you create constructor in Python?


➢ “init”


Syntax:

Example:

Output:

5. What is the purpose of Destructor? (PTA-2)




Part - III
Answer the following questions: 3 Marks
1. What are class members? How do you define it? (Sep 2021 , PTA-1)

..94.. A. PRABHAKAR-9442979144
– 10. PYTHON CLASSES AND OBJECTS
Example:


2. Write a class with two private class variables and print the sum using a method.
Program: (PTA-2)

3. Find the error in the following program to get the given output?

Output:

Error:

4. What is the output of the following program? (Mar 2020, Jul 2022)

..95.. A. PRABHAKAR-9442979144
– 10. PYTHON CLASSES AND OBJECTS

Output:

5. How do define constructor and destructor in Python? (Mar 2020, Mar 2024, PTA-4)
Syntax of Constructor:

Syntax of Destructor:

Example: Output:

Part - IV
Answer the following questions: 5 Marks
1. Explain about constructor and destructor with suitable example. (Sep 2020)
Constructor:

Syntax:

Example:

..96.. A. PRABHAKAR-9442979144
– 10. PYTHON CLASSES AND OBJECTS

Constructor of class Sample...


The value is : 10
Destructor:

Syntax:

Example:

Destructor of class Sample...

(PTA-2)
b) self
(PTA-5)

d) Creating an object
Find the output of the following Python code. (PTA-1)

..97.. A. PRABHAKAR-9442979144
– 10. PYTHON CLASSES AND OBJECTS
Output:

Write the syntax of class instantiation. (PTA-5)

What is the use of private and public data members? (Sep 2020, PTA-3)

What will be the output of the following Python code. (PTA-2)

..98.. A. PRABHAKAR-9442979144
– 10. PYTHON CLASSES AND OBJECTS

Output:

Rewrite the following Python program to get the given output: (PTA-3)

..99.. A. PRABHAKAR-9442979144
– 10. PYTHON CLASSES AND OBJECTS

Error Free Program:


class circle:
pi=3.14
def __init__ (self, radius):
self.radius=radius
def area(self):
return circle.pi * self.radius ** 2
def circumference(self):
return 2*circle.pi* self.radius
r = int(input("Enter radius= "))
c = circle(r)
print("The Area: ", c.area())
print("The circumference=",
c.circumference())

a) C

c) a) and b)

b) Object

b) Public

d) Dot(.)

d) _ _init_ _

c) Constructor

c) class

c) Colon(:)

a) Private

..100.. A. PRABHAKAR-9442979144
– 10. PYTHON CLASSES AND OBJECTS

a) Private

b) Public

a) indented

d) Destructor
15. How would you define a class in Python?

Syntax:

Exmple:

16. How will you create objects for a class?

Syntax:

Example:

✓ ‘S’

..101.. A. PRABHAKAR-9442979144
– 10. PYTHON CLASSES AND OBJECTS
17. How will you access class members?

Syntax:

Example:

Output:

18. Write about class methods.



self

self

..102.. A. PRABHAKAR-9442979144
11 DATABASE CONCEPTS

Part - I
Choose the best answer: 1 Mark
(Sep 2021)

c) DataBase Management System


(Jul 2022, Jun 2023)
c) relation
(Mar 2023)
c) Hierarchical
(Sep 2020)
a) E F Codd

(Jul 2024, PTA-4)


b) one-to-many

c) Edgar Frank Codd

c) Microsoft Access
(Mar 2020, Mar 2024, PTA-2)
a) σ Π
(May 2022, PTA-6)
b) row

a) Chen
Part - II
Answer the following questions: 2 Marks
1. Mention few examples of a database. (Jul 2022)
  
  
2. List some examples of RDBMS.
   
  

..103.. A. PRABHAKAR-9442979144
– 11. DATABASE CONCEPTS
3. What is data consistency? (Jun 2023)

4. What is the difference between Hierarchical and Network data model? (Mar 2024)


5. What is normalization?

Part - III
Answer the following questions: 3 Marks
1. What is the difference between Select and Project command? (PTA-2)
Select Project

symbol : σ symbol : ∏
2. What is the role of DBA? (Jun 2023)

3. Explain Cartesian product with a suitable example. (PTA-5)



Table A Table B
RollNo Name SubCode Subject

..104.. A. PRABHAKAR-9442979144
– 11. DATABASE CONCEPTS
Cartesian product : Table A x Table B
RollNo Name SubCode Subject

4. Explain Object Model with example.




5. Write a note on different types of DBMS users. (Sep 2020)
➢ Database Administrators:

➢ Application Programmers or Software Developers:

➢ End User:

➢ Database designers:

Part - IV
Answer the following questions: 5 Marks
1. Explain the different types of data model. (Sep 2020)
1. Hierarchical Model:

..105.. A. PRABHAKAR-9442979144
– 11. DATABASE CONCEPTS


2. Relational Model:



Stu_id Name Age Sub_id Subject Teacher


1 Aruna 17 1 Tamil Jegan
2 Prabhakar 16 2 Maths Veni
3 Aakash 15 3 Science Jeya

Stu_id Sub_id Marks


1 1 98
2 2 87
3 2 75
3. Network Model:



Parent
Node

Child to School (Parent Node)

Student has 3 Parents


(one to many relationship)

..106.. A. PRABHAKAR-9442979144
– 11. DATABASE CONCEPTS
4. Entity Relationship Model (ER model):





5. Object Model:



Example:

Shape

Circle Rectangl Triangle


e

..107.. A. PRABHAKAR-9442979144
– 11. DATABASE CONCEPTS





2. Explain the different types of relationship mapping. (Mar 2023, PTA-1, PTA-4)
1. One-to-One Relationship: Student Exam No

For example:

2. One-to-Many Relationship: Staff


Department

For example:

3. Many-to-One Relationship:
Staff Department

For example:

..108.. A. PRABHAKAR-9442979144
– 11. DATABASE CONCEPTS
4. Many-to-Many Relationship:
Book Student

For example:

3. Differentiate DBMS and RDBMS. (Mar 2020, Mar 2023, Jul 2024)
Basis of
DBMS RDBMS
Comparison

Expansion

Data storage

Data redundancy

Normalization

Data access

Keys and indexes

Transaction

Distributed

Example

4. Explain the different operators in Relational algebra with suitable examples.


(MAR 2024, PTA-2, PTA-4)
I. Unary Relational Operations:
SELECT (symbol : σ)
➢ σ

..109.. A. PRABHAKAR-9442979144
– 11. DATABASE CONCEPTS

PROJECT (symbol : Π)

Π
Result

II. Relational Algebra Operations from Set Theory: (Mar 2024)

Table A Table B
Studno Name Studno Name

..110.. A. PRABHAKAR-9442979144
– 11. DATABASE CONCEPTS
UNION (Symbol :∪)

➢ ∪
Result
Table A ∪ B
Studno Name

SET DIFFERENCE (Symbol : -)


Result
Table A B
Studno Name

INTERSECTION (symbol: ∩) A ∩ B

Result

Studno Name

PRODUCT OR CARTESIAN PRODUCT (Symbol: X)


..111.. A. PRABHAKAR-9442979144
– 11. DATABASE CONCEPTS
Table A Table B
RollNo Name SubCode Subject

Cartesian product : Table A x Table B


RollNo Name SubCode Subject

5. Explain the characteristics of RDBMS. (Sep 2021, Jul 2022, Jun 2023, PTA-3, PTA-5)
1. Ability to manipulate
data

2. Reduced Redundancy

3. Data Consistency

4. Support Multiple user


and Concurrent Access

5. Query Language

6. Security

7. DBMS Supports

(PTA-1)
a) Attribute
(PTA-3)

d) All of these
(PTA-5)
b)  ᓂ
..112.. A. PRABHAKAR-9442979144
– 11. DATABASE CONCEPTS
What are the advantages of RDBMS? (Sep 2020, Sep 2021, PTA-3)




What are the shapes to represent database structures in ER model? (PTA-2)



Write about Database Structure. (PTA-6)

o
o
o

d) Data

a) Information

b) 5

..113.. A. PRABHAKAR-9442979144
– 11. DATABASE CONCEPTS

b) Tuple

b) IBM

a) Hierarchical Model

b) 1970

d) 1976

a) Rectangle

b) Ellipse

c) Diamond

c) Relational Database Management System

a) Hierarchical Model

a) Dr. Edgar F Codd

a) One-to-One

a) One-to-One Relationship

d) Many-to-Many Relationship

..114.. A. PRABHAKAR-9442979144
– 11. DATABASE CONCEPTS

α c) X
19. What is Data?

Example:

20. What is an Information?

Example:

21. What is database?

22. What is DBMS?




23. What is Data Model?


24. What is Relational Algebra?


❖ Edgar F Codd

..115.. A. PRABHAKAR-9442979144
– 11. DATABASE CONCEPTS
25. Explain the components of DBMS.

1. Hardware:

2. Software:

3. Data:

4. Procedures/Methods:

5. DataBase Access Languages:

..116.. A. PRABHAKAR-9442979144
12 STRUCTURED QUERY LANGUAGE

Part - I
Choose the best answer: 1 Mark

a) DDL

d) ALTER
(Mar 2020, Jul 2022, Mar 2023)
a) DROP

(Jul 2024)
a) SELECT
(Sep 2021, May 2022, Jun 2023, Mar 2024)
b) ORDER BY
Part - II
Answer the following questions: 2 Marks
1. Write a query that selects all students whose age is less than 18 in order wise.

2. Differentiate Unique and Primary Key constraint. (Mar 2022, Jul 2024, PTA-6)
Unique Constraint Primary Key Constraint

3. Write the difference between table constraint and column constraint? (Jun 2023)
➢ Table constraint
➢ Column constraint:
4. Which component of SQL lets insert values in tables and which lets to create a table?
➢ DDL (Data Definition Language)
➢ DML (Data Manipulation Language)
5. What is the difference between SQL and MySQL? (PTA-5)
❖ SQL :
❖ MySQL :

..117.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE
Part - III
Answer the following questions: 3 Marks
1. What is a constraint? Write short note on Primary key constraint.

Primary Key Constraint:

2. Write a SQL statement to modify the student table structure by adding a new field.

3. Write any three DDL commands. (Sep 2021, PTA-1, PTA-2)


➢ Create:
➢ Alter:
➢ Drop:
➢ Truncate:

4. Write the use of Savepoint command with an example.


Syntax:

Example:

..118.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE

5. Write a SQL statement using DISTINCT keyword. (Mar 2022)


➢ The DISTINCT keyword is used along with the SELECT command to eliminate duplicate
rows in the table.
➢ This helps to eliminate redundant data.
For Example:
Admno Name Age Place

Place

Part - IV
Answer the following questions: 5 Marks
1. Write the different types of constraints and their functions. (Sep 2020, Sep 2021,
Jul 2022, PTA-3)

(i) Unique Constraint:


..119.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE

(ii) Primary Key Constraint:


(iii) DEFAULT Constraint:



(iv) Check Constraint:


(v) TABLE Constraint:




..120.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE
2. Consider the following employee table. Write SQL commands for the questions. (i) to
(v). (PTA-2)

(i) To display the details of all employees in descending order of pay.


(ii) To display all employees whose allowance is between 5000 and 7000.
(iii) To remove the employees who are mechanic.
(iv) To add a new row.
(v) To display the details of all employees who are operators.
SQL COMMANDS:

3. What are the components of SQL? Write the commands in each. (Mar 2024)

(i) DATA DEFINITION LANGUAGE


SQL commands which comes under Data Definition Language are:


➢ Create:
➢ Alter:

..121.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE
➢ Drop:
➢ Truncate:

(ii) DATA MANIPULATION LANGUAGE


SQL commands which comes under Data Manipulation Language are:


➢ Insert:
➢ Update:
➢ Delete:
(iii) DATA CONTROL LANGUAGE

SQL commands which come under Data Control Language are:


➢ Grant:
➢ Revoke:
(iv) TRANSACTIONAL CONTROL LANGUAGE (Mar 2020, Mar 2024)

SQL command which come under Transfer Control Language are:


➢ Commit:
➢ Roll back:
➢ Save point:
(v) DATA QUERY LANGUAGE

➢ Select:

..122.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE
4. Construct the following SQL statements in the student table. (Sep 2020, May 2022)
(i) SELECT statement using GROUP BY clause.
(ii) SELECT statement using ORDER BY clause.

(i) SELECT statement using GROUP BY clause.

(ii) SELECT statement using ORDER BY clause.

5. Write a SQL statement to create a table for employee having any five fields and create
a table constraint for the employee table. (Mar 2020)

(Sep 2020)
b) Grant
(PTA-1)
d) Revoke
(PTA-2)
d) TRUNCATE
(PTA-3)
d) Rollback

..123.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE
(PTA-4)
a) DDL
(PTA-5)

b) a-iv, b-i, c-ii, d-iii

(PTA-6)
b) UPDATE
What are DCL commands in SQL? (PTA-4)

Explain the different DML commands. (Mar 2023, PTA-4)

(1) INSERT command:


The command is used as follows:

Example:

(2) DELETE command:


The DELETE command is used as follows:

..124.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE
(3) UPDATE command:

The command is used as follows:

❖ Example:

Compare Delete, Truncate and Drop in SQL. (PTA-1, PTA-3)


DELETE:

TRUNCATE:

DROP:

Explain about the TCL commands with suitable examples. (PTA-1)

Commit :
Roll back :
Save point :

..125.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE

Gowri

Gowri

Gowri

Gowri
What are the functions performed by DDL? (PTA-6)

..126.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE

) b) Structured Query Language


) )

b) IBM’s Research Centre

) ) c) Sequel )

d) 2008

c) Constraint

a) Embedded Data Manipulation Language

a) Check

b) Default

b) ALL

A) DELETE

c) TRUNCATE

c) DESC
13. What is SQL?

..127.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE

14. What is CRUD?

15. What is database?

16. What are field and record?


17. Write the procedure to create a new database.

18. Explain the two types of DML.


❖ Procedural DML –
❖ Non-Procedural DML

19. Write the functions of SQL commands.

❖ Keywords

❖ Commands

❖ Clauses
❖ Arguments
20. Write the different types of constraints.
 
 

..128.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE
21. What is the use of default constraint?

Example:

22. What is the use of check constraint?



Example:

23. Differentiate TRUNCATE and DROP TABLE.


TRUNCATE DROP TABLE

Syntax: Syntax:

24. Explain SELECT command.


..129.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE
Syntax:

Example:
(1)

SELECT Admno, Name FROM Student;


(2)

SELECT * FROM STUDENT;


25. What are uses the of the keywords BETWEEN and NOT BETWEEN?

SELECT Admno, Name, Age FROM Student WHERE Age BETWEEN 18 AND 19;

SELECT Admno, Name, Age FROM Student WHERE Age NOT BETWEEN 18 AND 19;
26. Write about the keywords IN and NOT IN?

For Example:
SELECT Admno, Name, Place FROM Student WHERE Place IN (‘Chennai’, ‘Delhi’);

For example:
SELECT Admno, Name, Place FROM Student WHERE Place NOT IN (‘Chennai’, ‘Delhi’);

27. How can you search a NULL value field?

SELECT * FROM Student WHERE Age IS NULL;

..130.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE
28. Explain the processing skills of SQL.
1. Data Definition Language (DDL):

2. Data Manipulation Language (DML):

3. Embedded Data Manipulation Language:

4. View Definition:

5. Authorization:

6. Integrity:

7. Transaction control:

29. Tabulate the different data types in a database.


Data Type Description

..131.. A. PRABHAKAR-9442979144
– 12. STRUCTURED QUERY LANGUAGE
30. Explain the use of ALTER command.

(1) Command for inserting columns in table format:

Example:

(2) Command for modifying an existing column in the table:

Example:

(3) Command for renaming existing column:

For example,

(4) The command to remove a column or all columns:

For example,

..132.. A. PRABHAKAR-9442979144
13 PYTHON AND CSV FILES

Part - I
Choose the best answer: 1 Mark
(Mar 2020, Mar 2024)
a) Flat File
(May 2022, Jul 2024)

d) Carriage Return and Line Feed

c) csv

(Jul 2022, Mar 2023)


b) Binary mode
(Jun 2023)
a) next()

a) Line Terminator

b) mumbai,andheri

(PTA-1)
d) DictReader()

c) Modification

..133.. A. PRABHAKAR-9442979144
– 13. PYTHON AND CSV FILES

d) Exam,
Quarterly,
Halfyearly
Part - II
Answer the following questions: 2 Marks
1. What is CSV File? (Sep 2021, May 2022, Mar 2024)

2. Mention the two ways to read a CSV file using Python. (Sep 2020, PTA-2)

3. Mention the default modes of the File. (Mar 2023)

4. What is use of next() function? (Jul 2024)

5. How will you sort more than one column from a csv file? Give an example statement.

Example:

..134.. A. PRABHAKAR-9442979144
– 13. PYTHON AND CSV FILES

Output:

Part - III
Answer the following questions: 3 Marks
1. Write a note on open() function of python. What is the difference between the two
methods? (Jul 2022, PTA-1)
Python has a built-in function open() to open a file. file object,
handle,

The open() 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.
But “with open” statement ensures that the file is closed when the block inside with is
exited.
2. Write a Python program to modify an existing file. (Jul 2022)

Roll No Name City

The following program modifying the value of an existing row in student.csv

..135.. A. PRABHAKAR-9442979144
– 13. PYTHON AND CSV FILES

When we open the student.csv file with text editor, then it will show:
Roll No Name City

3. Write a Python program to read a CSV file with default delimiter comma (,).

4. What is the difference between the write mode and append mode.
(Sep 2021, PTA-2, PTA-5)
‘w’ - write mode:

‘a’ – append mode:

5. What is the difference between reader() method and DictReader() class? (Mar 2020)
reader() DictReader()

..136.. A. PRABHAKAR-9442979144
– 13. PYTHON AND CSV FILES
Part - IV
Answer the following questions: 5 Marks
1. Differentiate Excel file and CSV file. (Sep 2020, May 2022, Jul 2024, PTA-2)
Excel CSV

2. Tabulate the different file modes with its meaning.


Mode Description

3. Write the different methods to read a File in Python. (Jul 2022, Jun 2023, Mar 2024)

1. CSV Module’s Reader Function:


..137.. A. PRABHAKAR-9442979144
– 13. PYTHON AND CSV FILES

The syntax for csv.reader() is

✓ file object:
✓ delimiter:

✓ fmtparams:

Example:

2. Reading CSV File into A Dictionary:


Example:

4. Write a Python program to write a CSV File with custom quotes.

..138.. A. PRABHAKAR-9442979144
– 13. PYTHON AND CSV FILES
5. Write the rules to be followed to format the data in a CSV file. (PTA-5)


xxx,yyy  

ppp, qqq 
yyy, xxx

field_name1,field_name2,field_name3 
aaa,bbb,ccc 
zzz,yyy,xxx CRLF

Red , Blue

"Red","Blue","Green" 
Black,White,Yellow

Red, “,”, Blue CRLF


Red, Blue , Green

“Red, ” “Blue”, “Green”,


, , White

(Sep 2020)

d) Comma Separated Values


(PTA-2)
b) xls
(PTA-3)
b) x

..139.. A. PRABHAKAR-9442979144
– 13. PYTHON AND CSV FILES

(PTA-4)
b) skipinitialspace

(PTA-5)
b) DictReader
How csv.writer() function is used to create a normal CSV file in Python? (PTA-4)

✓ fileobject :
✓ delimiter :

✓ fmtparams :

What is Excel? (PTA-6)

1.
b) EXCEL ) )
2.

) b) double-quote(“)
) )
3.
c) rt
4.

a) a
5.
d) b
6.
d) +

..140.. A. PRABHAKAR-9442979144
– 13. PYTHON AND CSV FILES
7.
) ) ) d) close()
8.

b) dialect
9.
) b) writerow() ) )
10.

) ) ) d) writerows()
11.
d) \n or \r
12. Write the purpose of CSV file.
➢ file

13. How will you create a new CSV file using Microsoft Excel?

❖ →

14. Write the procedure to open CSV file in MS Excel.


by default CSV files should
open automatically in Excel when the file is double-clicked.
File → Open from the ,
15. What is Dialect?

16. What is the difference between writerow() and writerows() functions?



..141.. A. PRABHAKAR-9442979144
14 IMPORTING C++ PROGRAMS IN PYTHON

Part - I
Choose the best answer: 1 Mark
(Sep 2020)
d) HTML
(Mar 2023)
a) Wrapping

b) Application Programming Interface

(Mar 2020, May 2022)


d) Boost

(PTA-5)

b) Modular programming

(Sep 2021, Jun 2023)


a) OS module
(Jul 2022)
c) args variable

a) main(sys.argv[1:])

d) PYTHON
(PTA-6)

c) python filename

..142.. A. PRABHAKAR-9442979144
– 14. IMPORTING C++ PROGRAMS IN PYTHON
Part - II
Answer the following questions: 2 Marks
1. What is the theoretical difference between Scripting language and other programming
language? (Sep 2021)

2. Differentiate compiler and interpreter. (Jul 2022)


Compiler Interpreter

3. Write the expansion of (i) SWIG (ii)MinGW (Mar 2020, PTA-5)


SWIG -
MinGW -
4. What is the use of modules?


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




Part - III
Answer the following questions: 3 Marks
1. Differentiate PYTHON and C++. (Sep 2021, Jun 2023)
PYTHON C++

..143.. A. PRABHAKAR-9442979144
– 14. IMPORTING C++ PROGRAMS IN PYTHON

2. What are the applications of scripting language? (Sep 2020, Mar 2024, PTA-4)

3. What is MinGW? What is its use? (Jul 2024)


4. Identify the module, operator, definition name for the following. (Jul 2022)

5. What is sys.argv? What does it contain? (Mar 2022)





Part - IV
Answer the following questions: 5 Marks
1. Write any 5 features of Python. (Mar 2020, Jun 2023, Mar 2024)




..144.. A. PRABHAKAR-9442979144
– 14. IMPORTING C++ PROGRAMS IN PYTHON

2. Explain each word of the following command. (May 2022)




3. What is the purpose of sys, os, getopt module in Python. Explain.


Python’s sys module:

sys argv
sys.argv:



Python's OS Module:
➢ OS

➢ OS


compiler
os.system (‘g++ ’ + <variable_name1> ‘ -<mode> ’ + <variable_name2>
Python getopt module:


getopt.getopt function:

<opts>,<args>=getopt.getopt(argv, options, [long_options])

..145.. A. PRABHAKAR-9442979144
– 14. IMPORTING C++ PROGRAMS IN PYTHON
4. Write the syntax for getopt() and explain its arguments and return values. (Mar 2022,
Mar 2023, PTA-2, PTA-5)

Syntax:
<opts>,<args>=getopt.getopt(argv, options, [long_options])
the parameters:
✓ argv −
✓ options −

✓ long_options −

The return values:


✓ getopt() returns value consisting of two elements
opts args
✓ opts
✓ args
args
For example:

5. Write a Python program to execute the following c++ coding.

Python Program:
# Save the following python programs as “myprg.py”

..146.. A. PRABHAKAR-9442979144
– 14. IMPORTING C++ PROGRAMS IN PYTHON

(PTA-1)
b) __name__
(PTA-3)
a) pycpp.py рус
(PTA-4)
a) __name__
4. Write about the steps of Python program executing C++ program using control
statement. (Mar 2023)
Step 1 :

Step 2 :
Step 3 : .
Step 4 :

a) Python

b) SWIG

) b) Minimalist GNU for Windows


) )

)
)
)
d) Simplified Wrapper Interface Generator

) )
c) Boost )
..147.. A. PRABHAKAR-9442979144
– 14. IMPORTING C++ PROGRAMS IN PYTHON

b) Ruby

c) cls
8.
a) import ) ) )
9. of the following is not a module in Python?
) ) c) argv )

c) argv

b) getopt
12. Write short note on Scripting Language.

13. List some scripting languages.


   
   
14. What is Garbage Collection?

15. Name some of the commonly used interfaces to import C++ files in Python.
  
  
16. What is g++?

17. Explain __name__ (A Special variable) in Python.


..148.. A. PRABHAKAR-9442979144
– 14. IMPORTING C++ PROGRAMS IN PYTHON

__name__ is one such special variable which by default stores the name of the file.


➢ __name__ is a built-in variable which evaluates to the name of the current module.

For example:
if __name__ == '__main__':
main (sys.argv[1:])

..149.. A. PRABHAKAR-9442979144
15 DATA MANIPULATION THROUGH SQL

Part - I
Choose the best answer: 1 Mark
(Mar 2020)
a) Database
(Sep 2021, May 2022)
b) Relational Database system

c) Cursor

c) Commit

a) execute()

c) AVG()
(Jul 2022, Mar 2023)
a) MAX()
(PTA-6)
a) sqlite_master
(Jun 2023, Mar 2024)
b) select
(Jul 2024, PTA-5)
a) Distinct
Part - II
Answer the following questions: 2 Marks
1. Mention the users who uses the Database.

2. Which method is used to connect a database? Give an example. (PTA-3)

..150.. A. PRABHAKAR-9442979144
– 15. DATA MANIPULATION THROUGH SQL
Example:

3. What is the advantage of declaring a column as “INTEGER PRIMARY KEY”? (Mar 2020)


4. Write the command to populate record in a table. Give an example.

Example:

5. Which method is used to fetch all rows from the database table? (Jul 2022, Mar 2024)

Example:

Part - III
Answer the following questions: 3 Marks
1. What is SQLite? What is it advantage? (PTA-1)

Advantages:



2. Mention the difference between fetchone() and fetchmany(). (Mar 2020, Jul 2022, Mar
2023, Jul 2024, PTA-4)
fetchone() fetchmany()

..151.. A. PRABHAKAR-9442979144
– 15. DATA MANIPULATION THROUGH SQL

3. What is the use of Where clause? Give a python statement using the where clause.
(May 2022, Mar 2024)

cursor.execute("SELECT DISTINCT (Grade) FROM student


where gender='M'")
result = cursor.fetchall()
print(*result, sep="\n")
4. Read the following details. Based on that write a python script to display department
wise records. (PTA-5, PTA-6)

Python script:

..152.. A. PRABHAKAR-9442979144
– 15. DATA MANIPULATION THROUGH SQL
5. Read the following details. Based on that write a python script to display records in
descending order of Eno

Python script:

Part - IV
Answer the following questions: 5 Marks
1. Write in brief about SQLite and the steps used to use it. (Jul 2022, Jun 2023)



To use SQLite,
✓ Step 1 -
✓ Step 2 -

..153.. A. PRABHAKAR-9442979144
– 15. DATA MANIPULATION THROUGH SQL
✓ Step 3 -

Example:

2. Write the Python script to display all the records of the following table using
fetchmany(). (Sep 2021, PTA-1)

Python script:

3. What is the use of HAVING clause. Give an example python script. (PTA-5)


Example:

..154.. A. PRABHAKAR-9442979144
– 15. DATA MANIPULATION THROUGH SQL

OUTPUT:

4. Write a Python script to create a table called ITEM with following specification.

Python script:

5. Consider the following table Supplier and item. Write a python script for (i) to (ii)

..155.. A. PRABHAKAR-9442979144
– 15. DATA MANIPULATION THROUGH SQL

Python script:

# i) Display Name, City and Itemname of suppliers who do not reside in Delhi.

# ii) Increment the SuppQty of Akila by 40

(Sep 2020)

d) COUNT()
PTA-2)

c) execute
(PTA-3)
a) SELECT

(PTA-4)
c) cursor
Write a Python code to create a database in SQLite. (PTA-3)


..156.. A. PRABHAKAR-9442979144
– 15. DATA MANIPULATION THROUGH SQL
Write a Python program to store and retrieve the following data in SQLite3. (PTA-4)

..157.. A. PRABHAKAR-9442979144
– 15. DATA MANIPULATION THROUGH SQL

Write a note on aggregate functions of SQL. (PTA-6)

 COUNT() :

Example:

Output:

 AVG() :

Example:

..158.. A. PRABHAKAR-9442979144
– 15. DATA MANIPULATION THROUGH SQL
Output:

 SUM() :

Example:

Output:

 MAX() AND MIN() :



Output:

..159.. A. PRABHAKAR-9442979144
– 15. DATA MANIPULATION THROUGH SQL
Write a Python code to display all the records of the following table using fetchmany().
(PTA-1)

Python script:

c) fetchmany()

b) *

a) HAVING

b) WHERE

a) b) c) WHERE() d)

a) b) c) d) COUNT()

a) 1 b) 4 c) 3 d) 2

c) ? and :name

..160.. A. PRABHAKAR-9442979144
– 15. DATA MANIPULATION THROUGH SQL

b) “/” or “\”
What is the use of cursor object?

Write short note on fetchall(), fetchone() and fetchmany().




List out various clauses in SQL?
  
 
Write short note on cursor.description().



What is Sqlite_master?

How will you show the table list created in a database?

Example:

Output:

What is the use of select query?


..161.. A. PRABHAKAR-9442979144
– 15. DATA MANIPULATION THROUGH SQL

Example:

..162.. A. PRABHAKAR-9442979144
DATA VISUALIZATION USING PYTHON:
16
LINE CHART, PIE CHART AND BAR CHART

Part - I
Choose the best answer: 1 Mark

a) matplotlib.pyplot

b) PIP

d) Data Visualization

(Mar 2024)
b) Dashboard

(Jul 2024)
d) matplotlib

Line Chart or Line Graph

..163.. A. PRABHAKAR-9442979144
– 16. DATA VISUALIZATION

a) Line chart

c) Both the statements are correct


Part - II
Answer the following questions: 2 Marks
1. What is Data Visualization. (May 2022)

2. List the general types of data visualization. (Mar 2020, Jul 2022, Mar 2023, Jul 2024)
❖ ❖ ❖
❖ ❖ ❖
3. List the types of Visualizations in Matplotlib. (Sep 2020, Mar 2024)
❖ ❖ ❖
❖ ❖ ❖
4. How will you install Matplotlib?

5. Write the difference between the following functions: plt.plot([1,2,3,4]),


plt.plot([1,2,3,4], [1,4,9,16]).
Case 1: plt.plot([1,2,3,4])

Case 2: plt.plot([1,2,3,4], [1,4,9,16])

..164.. A. PRABHAKAR-9442979144
– 16. DATA VISUALIZATION
Part - III
Answer the following questions: 3 Marks
1. Draw the output for the following data visualization plot.

Output:

2. Write any three uses of data visualization. (May 2022, PTA-1, PTA-5)


3. Write the plot for the following pie chart output.

..165.. A. PRABHAKAR-9442979144
– 16. DATA VISUALIZATION
Code:

Part - IV
Answer the following questions: 5 Marks
1. Explain in detail the types of pyplots using Matplotlib. (PTA-6)
Line Chart:

Example: Output:

Bar Chart:




..166.. A. PRABHAKAR-9442979144
– 16. DATA VISUALIZATION
Example: Output:

Pie Chart:



➢ plt.pie()

Example: Output:

2. Explain the various buttons in a matplotlib window. (Mar 2024, PTA-5)

➢ Home Button:
➢ Forward/Back buttons:

➢ Pan Axis:

..167.. A. PRABHAKAR-9442979144
– 16. DATA VISUALIZATION
➢ Zoom:

➢ Configure Subplots:

➢ Save Figure:
3. Explain the purpose of the following functions: (May 2022)
a. plt.xlabel
b. plt.ylabel
c. plt.title
d. plt.legend()

e. plt.show()

(Sep 2021)
b) plt.show()

(PTA-1)
a) Matplotlib
(PTA-2)
d) plt.pie()
(PTA-3)
d) SQLite
(PTA-4)
c) Scatter plot
(PTA-5)
d) plot()
(PTA 6)
a) Markers
What is Matplotlib? (PTA-2)

What is Pip? (PTA-6)

What is pie chart? How will you create pie chart in Python? Give an example. (PTA-3)

..168.. A. PRABHAKAR-9442979144
– 16. DATA VISUALIZATION

Creating Pie chart:
❖ plt.pie()

Example: Output:

Draw the output for the following Python code. (PTA-3)


Output:

Draw the chart for the given Python snippet. (PTA-4)

Output:

..169.. A. PRABHAKAR-9442979144
– 16. DATA VISUALIZATION
What are the Key Differences Between Histogram and Bar Graph? (Sep 2021, Mar 2023,
PTA-4)

b) Data Visualization

b) Infographics

a) Dashboard

a) Bar chart

d) Histogram

b) Pan Axis

..170.. A. PRABHAKAR-9442979144
– 16. DATA VISUALIZATION

c) Configure Subplots button

c) a) and b)
9. What is an Infographic?

10. What is Dashboard?


11. What is histogram?

12. What is scatter plot?

13. What is Box plot?

..171.. A. PRABHAKAR-9442979144
PRACTICAL EXERCISES

1(a) Write a program to calculate the factorial of the given number using for loop (Don’t use built-
in function factorial).
PY1(a) – CALCULATE FACTORIAL
AIM:
Program to calculate the factorial of the given number using for loop.
CODING:
num = int(input('Enter a Number: '))
fact = 1
for i in range(1,num+1):
fact = fact * i
print("Factorial of ", num, " is ", fact)
OUTPUT:
Enter a Number: 6
Factorial of 6 is 720
CONCLUSION:
The factorial of the given number is calculated successfully using for loop.

1(b). Write a program to sum the series:1/1 + 22 /2 + 33 /3 + ……. nn/n.


PY1(b) – SUM OF SERIES
AIM:
Program to sum the given series.
CODING:
n = int(input("Enter a value of n: "))
s = 0
for i in range(1,n+1):
a= (i**i)/i
s=s+a
print("The sum of the series is ", s)
OUTPUT:
Enter a value of n: 4
The sum of the series is 76.0
CONCLUSION:
The sum of the given series is calculated successfully.

..172.. A. PRABHAKAR-9442979144
– PRACTICAL EXERCISES
2(a). Write a program using functions to check whether a number is even or odd.
PY2(a) – ODD OR EVEN
AIM:
Program to check whether a number is even or odd using functions.
CODING:
def oddeven(a):
if (a%2==0):
return "Even"
else:
return "Odd"
num = int(input("Enter a number: "))
print("The given number is ", oddeven(num))
OUTPUT:
Enter a number : 5
The Given number is Odd
Enter a number : 8
The Given number is Even
CONCLUSION:
It was successfully verified whether the given number is even or odd.

2(b) Write a program to create reverse of the given string. For example, “wel” = “lew“. (Don’t use
string slice with stride operation)
PY2(b) – REVERSE THE STRING
AIM:
Program to create a mirror image of the given string.
CODING:
def reverse(str1):
str2=''
for i in str1:
str2 = i + str2
return str2
word = input("Enter a String: ")
print("The reverse of the given string is:", reverse(word))
OUTPUT:
Enter a String: School
The reverse of the given string is: loohcS
CONCLUSION:
The mirror image of the given string is displayed successfully.

..173.. A. PRABHAKAR-9442979144
– PRACTICAL EXERCISES
3. Write a program to generate values from 1 to 10 and then remove all the odd numbers from the
list.
PY3 - GENERATE VALUES AND REMOVE ODD NUMBERS
AIM:
Program to generate values from 1 to 10 and then remove all the odd numbers from the
list.
CODING:
num = list(range(1,11))
print("Numbers from 1 to 10.....\n",num)
for i in num:
if(i%2 == 1):
num.remove(i)
print("The values after removing odd numbers.....\n",num)
OUTPUT:
Numbers from 1 to 10.....
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
The values after removing odd numbers.....
[2, 4, 6, 8, 10]
CONCLUSION:
Generated values from 1 to 10 in a list and successfully removed all odd numbers.
4. Write a Program that generate a set of prime numbers and another set of odd numbers. Display
the result of union, intersection, difference and symmetric difference operations.
PY4 - GENERATE PRIME NUMBERS AND SET OPERATIONS
AIM:
Program to generate a set of prime numbers and another set of odd numbers and then
perform various set operations.
OUTPUT:
CODING:
Odd Number: {1, 3, 5, 7, 9}
odd = set(range (1,10,2))
Prime Number: {2, 3, 5, 7}
prime=set()
Union: {1, 2, 3, 5, 7, 9}
for i in range(2,10):
Intersection: {3, 5, 7}
for j in range (2,i):
Difference: {1, 9}
if (i%j==0):
Symmetric_Difference:{1,2,9}
break
CONCLUSION:
else:
The set of prime numbers
prime.add(i)
and odd numbers are generated
print("Odd Numbers:", odd)
and then performed various set
print("Prime Numbers:", prime) operations successfully.
print("Union:", odd.union(prime))
print("Intersection:", odd.intersection(prime))
print("Difference:", odd.difference(prime))
print("Symmetric Difference:", odd.symmetric_difference(prime))

..174.. A. PRABHAKAR-9442979144
– PRACTICAL EXERCISES
5. Write a program to accept a string and print the number of uppercase, lowercase, vowels,
consonants and spaces in the given string using Class.
PY5 - DISPLAY A STRING ELEMENTS – USING CLASS
AIM:
Program to accept a string and print the number of uppercase, lowercase, vowels,
consonants and spaces in the given string using Class.
CODING:
class String:
def __init__(self):
self.u = 0
self.l = 0
self.v = 0
self.c = 0
self.b = 0
self.str = ''
def getstr(self):
self.str = input("Enter a String : ")
for ch in self.str:
if (ch.isupper()):
self.u += 1
if (ch.islower()):
self.l += 1
if (ch in('aeiouAEIOU')):
self.v += 1
if (ch == " "):
self.b += 1
self.c = self.u + self.l - self.v
def display(self):
print("The given String is : ",self.str)
print("Upper case Letters : ",self.u)
print("Lower Letters : ",self.l)
print("Vowels Letters : ",self.v)
print("Constant Letters : ",self.c)
print("Blank Space : ",self.b)
s = String()
s.getstr()
s.display()
OUTPUT:
Enter a String : Welcome to Computer Science
The given String is : Welcome to Computer Science
Upper case Letters : 3
Lower Letters : 21

..175.. A. PRABHAKAR-9442979144
– PRACTICAL EXERCISES
Vowels Letters : 10
Constant Letters : 14
Blank Space : 3
CONCLUSION:
The number of uppercase, lowercase, vowels, consonants and spaces are counted
successfully in the given string using class.
6. Create an Employee Table with the fields Empno, Empname, Desig, Dept, Age and Place. Enter
five records into the table
• Add two more records to the table.
• Modify the table structure by adding one more field namely date of joining.
• Check for Null value in doj of any record.
• List the employees who joined after 2018/01/01.
DB6 – MYSQL EMPLOYEE TABLE
AIM:
Create a database table named as “Employee” and insert the records into it, change the
structure of the table and select the required records from the table using SQL.
SQL QUERIES AND OUTPUT:
(i) Creating Table Employee:
mysql> Create table Employee
(Empno integer(4) primary key,
Empname varchar(20),
Desig varchar(10),
Dept varchar(10),
Age integer(2),
Place varchar(10));
(ii) View Table Structure:
mysql> Desc Employee;

(iii) Inserting Data into Table:


mysql>INSERT INTO ‘employee’ VALUES ('101', 'Aakash', 'Officer', 'Accounts', '45', 'Udumalpet');
mysql>INSERT INTO ‘employee’ VALUES ('102', 'Bharathi', 'Manager', 'Admin', '32', 'Salem');

..176.. A. PRABHAKAR-9442979144
– PRACTICAL EXERCISES
mysql> INSERT INTO ‘employee’ VALUES ('103', 'Ashok', 'Clerk', 'Accounts', '33', 'Tiruppur');
mysql> INSERT INTO ‘employee’ VALUES ('104', 'Vimal', 'Manager', 'Admin', '28', 'Udumalpet');
mysql> INSERT INTO ‘employee’ VALUES ('105', 'Yuvaraj', 'Officer', 'Accounts', '31', 'Tiruppur');
(iv) Select all the record:
mysql> select * from Employee;

(v) Adding two more records:


mysql> Insert into employee values(3226, 'Sona', 'Manager', 'Accounts', 42, 'Erode');
mysql> Insert into employee values(3227, 'Rekha', 'Officer', 'Admin', 34, 'Salem');
mysql> SELECT * FROM ‘employee’;

(vi) Adding one more Field:


mysql> Alter table employee add(doj date);
mysql> desc employee;

(vii) Inserting date of joining to each employee:


mysql> update employee set doj = '21-03-2010' where empno=1221;
mysql> update employee set doj = '13-05-2012' where empno=1222;

..177.. A. PRABHAKAR-9442979144
– PRACTICAL EXERCISES
mysql> update employee set doj = '25-10-2017' where empno=1223;
mysql> update employee set doj = '17-06-2018' where empno=1224;
mysql> update employee set doj = '02-01-2018' where empno=1225;
mysql> update employee set doj = '31-12-2017' where empno=3226;
mysql> update employee set doj = '16-08-2015' where empno=3227;
mysql> select * from Employee;

(viii) Checking null value in doj:


mysql> select * from emp where empno is null;

Empty set
(ix) List the employees who joined after 01/01/2018:
mysql> Select * from emp where doj > '01-01-2018';

CONCLUSION:
An “Employee” database table was created and inserted the records into it, changed
the structure of the table and selected the required records from the table using SQL.
7. Create a table with following fields and enter data as given in the table below.

..178.. A. PRABHAKAR-9442979144
– PRACTICAL EXERCISES

Data to be entered:

Then, query the followings:


(i) List the students whose department is “Computer Science”.
(ii) List all the students of age 20 and more in Mechanical department.
(iii) List the students department wise.
(iv) Modify the class M2 to M1.
(v) Check for the uniqueness of Register no.
DB7 - MYSQL – STUDENT TABLE
AIM:
Create a database table named as “Student” and insert the records into it. Select and
update the records from the table using SQL.
SQL வினவல்கள் மற்றும் வவளியீடுகள்:
(1) Creating Table - Student:
mysql> Create table Student (Reg_No char(5), Sname varchar(15),
Age integer(2), Dept varchar(10), Class char(3));
View table structure:
mysql> Desc Student;

(2) Inserting Data into table:


mysql> insert into student values('M1001','Harish',19,'ME','ME1');
mysql> insert into student values('M1002','Akash',20,'ME','ME2');
mysql> insert into student values('C1001','Sneha',20,'CSE','CS1');
mysql> insert into student values('C1002','Lithya',19,'CSE','CS2');
mysql> insert into student values('E1001','Ravi',20,'ECE','EC1');
mysql> insert into student values('E1002','Leena',21,'EEE','EE1');

..179.. A. PRABHAKAR-9442979144
– PRACTICAL EXERCISES
mysql> insert into student values('E1003','Rose',20,'ECE','EC2');
View all records:
mysql> select * from Student;

(3) Other Queries:


(i) List the students whose department is “CSE”:
mysql> Select * from Student where Dept='CSE';

(ii) List all the students of age 20 and more in ME department:


mysql> Select * from Student where Age >=20 and Dept='ME';

(iii) List the students department wise:


mysql> Select * from Student Group by Dept Order by Sname;

(iv) Modify the class M2 to M1:


mysql> Update Student set Class='ME1' where Class='ME2';

..180.. A. PRABHAKAR-9442979144
– PRACTICAL EXERCISES
mysql> select * from Student;

(v) Check for the uniqueness of Register no.:


mysql> Select Distinct Reg_No from Student;

CONCLUSION:
The “Student” table was created and inserted the records into it and selected as well
as updated the records from the table using SQL.
8. Write a program using python to get 10 players name and their score. Write the input in a csv
file. Accept a player name using python. Read the csv file to display the name and the score. If the
player name is not found give an appropriate message.

PY PYTHON WITH CSV


AIM:
Create a CSV file and write the name and score of 10 players which were read using the
Python program. Read and display the player’s name and score. If the player's name is not
found, give an appropriate message.
CODING:
import csv
with open('d:\Python313\player.csv','w') as f:
w = csv.writer(f)
n = 1

..181.. A. PRABHAKAR-9442979144
– PRACTICAL EXERCISES
while(n <= 10): OUTPUT:
name = input("Player Name: ") Player Name: Dhoni
score = int(input("Score: ")) Score: 183
Player Name: Sachin
w.writerow([name,score])
Score: 200
n += 1 Player Name: Sehwag
print("Player File created") Score: 219
f.close() Player Name: Rohit
Score: 264
searchname = input("Enter the name to be searched: ")
Player Name: Virat
f = open('d:\Python313\player.csv','r') Score: 183
reader = csv.reader(f) Player Name: Ganguly
lst = [] Score: 183
for row in reader: Player Name: Dravid
lst.append(row) Score: 153
q = 0 Player Name: MS
Dhoni
for row in lst:
Score: 224
if searchname in row:
Player Name: Karthik
print(row)
Score: 79
q += 1
Player Name: Ashwin
if(q == 0): Score: 65
print("String not found")
Player File created
f.close()
Enter the name to be
CONCLUSION:
searched: Dhoni
A CSV file is created and performed read and write operations ['Dhoni', '183']
successfully.
9. Create a sql table using python and accept 10 names and age .sort in descending order of age
and display.
PY9 – PYTHON WITH SQL
AIM:
Program to create a SQL table that accepts the name and age of 10 students and then
shows the data in descending order based on the age of the students.
CODING:
import sqlite3
connection =sqlite3.connect("info.db")
cursor=connection.cursor()
cursor.execute("create table student(name,age)")
print("Enter 10 students name and their age respectively:")
for i in range(10):
who=[input("Enter Name: ")]
age=[int(input("Enter Age: "))]
n=len(who)

..182.. A. PRABHAKAR-9442979144
– PRACTICAL EXERCISES
for i in range(n):
cursor.execute("insert into student values(?,?)",(who[i], age[i]))
cursor.execute("select * from student order by age desc")
print("Displaying All the Records From student Table in Descending order of age:")
print(*cursor.fetchall(),sep='\n')
OUTPUT:
Enter 10 students name and their age respectively:
Enter Name: ALEX
Enter Age: 17
Enter Name: ASHOK
Enter Age: 19
Enter Name: BHARATHI
Enter Age: 17
Enter Name: RAMAKRISHNAN
Enter Age: 16
Enter Name: SARATHI
Enter Age: 19
Enter Name: NAVANEETHAN
Enter Age: 21
Enter Name: KISHORE
Enter Age: 14
Enter Name: VIMAL
Enter Age: 18
Enter Name: YUVARAJ
Enter Age: 13
Enter Name: PADMANATHAN
Enter Age: 20
Displaying All the Records From student Table in Descending order of age:
('NAVANEETHAN', 21)
('PADMANATHAN', 20)
('ASHOK', 19)
('SARATHI', 19)
('VIMAL', 18)
('ALEX', 17)
('BHARATHI', 17)
('RAMAKRISHNAN', 16)
('KISHORE', 14)
('YUVARAJ', 13)
CONCLUSION:
A SQL table created and stored the name and age of 10 students using Python and then
successfully displayed the data in descending order based on the age of the students.

..183.. A. PRABHAKAR-9442979144
– PRACTICAL EXERCISES
10. Write a program to get five marks using list and display the marks in pie chart.
PY10 – PYTHON GRAPHICS WITH PIP
AIM:
Program to get five marks using list and display the marks in pie chart.
CODING:
import matplotlib.pyplot as plt
marks=[]
i=0
subjects = ["Tamil", "English", "Maths", "Science", "Social"]
while i<5:
marks.append(int(input("Enter Mark = ")))
i+=1
for j in range(len(marks)):
print("{}.{} Mark = {}".format(j+1, subjects[j],marks[j]))
plt.pie (marks, labels = subjects, autopct = "%.2f ")
#plt.axes().set_aspect("equal")
plt.show()
OUTPUT:
Enter Mark = 99
Enter Mark = 78
Enter Mark = 100
Enter Mark = 89
Enter Mark = 88
1.Tamil Mark = 99
2.English Mark = 78
3.Maths Mark = 100
4.Science Mark = 89
5.Social Mark = 88
CONCLUSION:
The five subject marks are displayed in a pie chart successfully.

..184.. A. PRABHAKAR-9442979144
MARCH - 2024

Register Number
PART-II
COMPUTER SCIENCE
(English Version)
Time Allowed : 3.00 Hours ] [ Maximum Marks : 70

Instructions : (1) Check the question paper for fairness of printing. If there is any
lack of fairness, inform the Hall Supervisor immediately.
(2) Use Blue or Black ink to write and underline and pencil to draw
diagrams.
PART - I
Note : i) Answer all the questions. 15 x 1 = 15
ii) Choose the most appropriate answer from the given four alternatives and write
the option code and the corresponding answer.
1. Which of the following is used to describe the worst case of an algorithm?
a) Big W b) Big A c) Big O d) Big S
2. The datatype whose representation is unknown are called as:
a) Concrete datatype b) Built-in datatype c) Abstract datatype d) Derived datatype
3. Which key is pressed to execute Python Script?
a) F1 b) F5 c) F3 d) F2
4. Which of the following defines what an object can do?
a) Interface b) Operating System c) Interpreter d) Compiler
5. Which of the following security technique that regulates who can view or use resources in a computing
environment?
a) Access control b) Password c) Certification d) Authentication
6. Which of the following is the Slicing Operator?
a) <> b) {} c) () d) []
7. In Python the process of creating an object is called as
a) Initialize b) Constructor c) Instantiation d) Destructor
8. Pick the correct one to execute the given statement successfully.
if : print(x, "is a leap year")
a) x / 4 = 0 b) x% * 2 = 0 c) x% * 4 = 0 d) x% * 4 ==0
9. What symbol is used for SELECT statement?
a) X b) σ c) Ω d) Π

..185.. A. PRABHAKAR-9442979144
– MARCH 2024
10. If List [10, 20, 30, 40, 50] then List [2] = 35 will result:
a) [10, 20, 35, 40, 50] b) [35, 10, 20, 30, 40, 50]
c) [10, 35, 30, 40, 50] d) [10, 20, 30, 40, 50, 35]
11. A CSV file is also known as a
a) String File b) Flat File c) Random File d) 3D File
12. The most commonly used statement in SQL is:
a) execute b) cursor c) commit d) select
13. What is the output of the following snippet in Python?
for x in range (5):
if x==2:
continue
print(x, end =’ ‘)
a) 0 1 3 4 b) 0 1 2 c) 0 1 2 3 4 d) 0 1 2 3
14. is a collection of resources assembled to create a single unified visual display.
a) Objects b) Interface c) Graphics d) Dashboard
15. The clause used to sort data in a database:
a) GROUP BY b) SORT BY c) SELECT d) ORDER BY
PART II
Note : Answer any six questions. Question No. 24 is compulsory. 6 x 2 = 12
16. What is abstract data type?
17. What are the different operators that can be used in Python?
18. What is searching? Write its types.
19. Write the different types of function.
20. List the types of visualizations in Matplotlib.
21. What is the difference between Hierarchical and Network data model?
22. What is CSV file?
23. Which method is used to fetch all rows from the database table?
24. Write the use of pop() function in Python.
PART – III
Note : Answer any six questions. Question No. 33 is compulsory. 6 x 3 = 18
25. Differentiate pure and impure function.
26. What are the different ways to access the elements of a list? Give example.
27. Write a note on Asymptotic notation.
28. Using if..else..elif statement write a suitable program to display largest of 3 numbers.
29. Write a short note for the followings with suitable example.
a) capitalize() b) swapcase()

..186.. A. PRABHAKAR-9442979144
– MARCH 2024
30. How will you define Constructor and Destructor in Python?
31. What are the applications of scripting language?
32. What is the use of Where clause? Give a Python statement by using Where clause.
33. Write short notes on TCL Commands in SQL.
PART – IV
Note : Answer all the following questions. 5 x 5 = 25
34. a) How will you facilitate data abstraction? Explain it with suitable example.

b) What is Binary Search? Explain it with example.


35. a) Explain input() and print() functions with examples.

b) Explain the scope of variables with an example.


36. a) What is the purpose of range() function? Explain with an example.

b) Explain the following operators in Relational algebra with suitable examples.


(i) UNION (ii) INTERSECTION (iii) DIFFERENCE (iv) CARTESIAN PRODUCT
37. a) What are the components of SQL? Write the commands for each.

b) Discuss the features of Python over C++.


38. a) Write the different methods to read a file in Python.

b) Explain the various buttons in a matplotlib window.

-o0o-

..187.. A. PRABHAKAR-9442979144

You might also like