12CS em MLM
12CS em MLM
COMPUTER SCIENCE
(Minimum learning material)
A. Prabhakar - 9442979144
12
ARUNA PUBLICATIONS
techeasyforstudents@gmail.com
Important One Marks
LESSON 1 - FUNCTIONS
1. The small sections of code that are used to perform a particular task is called
(A) Subroutines (B) Files (C) Pseudo code (D) Modules
2. Which of the following is a distinct syntactic block?
(A) Subroutines (B) Function (C) Definition (D) Modules
3. The variables in a function definition are called as
(A) Subroutines (B) Function (C) Definition (D) Parameters
4. The values which are passed to a function definition are called
(A) Arguments (B) Subroutines (C) Function (D) Definition
5. Which of the following defines what an object can do?
(A) Operating System (B) Compiler (C) Interface (D) Interpreter
6. The functions which will give exact result when same arguments are passed are called
(A) Impure functions (B) Partial Functions (C) Dynamic Functions (D) Pure functions
7. The functions which cause side effects to the arguments passed are called
(A) Impure function (B) Partial Functions (C) Dynamic Functions (D) Pure functions
LESSON 2 - DATA ABSTRACTION
8. Which of the following functions that build the abstract data type?
(A) Constructors (B) Destructors (C) recursive (D)Nested
9. Which of the following functions that retrieve information from the data type?
(A) Constructors (B) Selectors (C) recursive (D)Nested
10. The data structure which is a mutable ordered sequence of elements is called
(A) Built in (B) List (C) Tuple (D) Derived data
11. A sequence of immutable objects is called
(A) Built in (B) List (C) Tuple (D) Derived data
12. The data type whose representation is known are called
(A) Built in datatype (B) Derived datatype
(C) Concrete datatype (D) Abstract datatype
13. The data type whose representation is unknown are called
(A) Built in datatype (B) Derived datatype
(C) Concrete datatype (D) Abstract datatype
14. Bundling two values together into a compound structure
(A) Pair (B) Triplet (C) single (D) quadrat
15. Which of the following allow to name the various parts of a multi-item object?
(A) Tuples (B) Lists (C) Classes (D) quadrats
16. Which of the following is constructed by placing expressions within square brackets?
(A) Tuples (B) Lists (C) Classes (D) quadrats
LESSON 3 - SCOPING
17. Which of the following refers to the visibility of variables in one part of a program to another part of the
same program.
(A) Scope (B) Memory (C) Address (D) Accessibility
18. The process of binding a variable name with an object is called
(A) Scope (B) Mapping (C) late binding (D) early binding
19. Which of the following is used in programming languages to map the variable and object?
(A) :: (B) := (C) = (D) ==
LESSON 1 - FUNCTIONS
1. What is a subroutine?
Subroutines are small sections of code that are used to perform a particular task that can be used
repeatedly. In Programming languages these subroutines are called as Functions.
2. Differentiate interface and implementation.
Interface Implementation
Interface just defines what an object can do, but Implementation carries out the instructions defined
won’t actually do it. in the interface.
3. Which of the following is a normal function definition and which is recursive function definition
i) let sum x y: return x + y Answers:
ii) let disp: (i) Recursive function
print ‘welcome’ ii) Normal Function
iii) let sum num: iii) Recursive Function
if (num!=0) then return num + sum
(num-1)
else
return num
4. Mention the characteristics of Interface.
➢ The class template specifies the interfaces to enable an object to be created and operated properly.
➢ An object's attributes and behaviour are controlled by sending functions to the object.
5. Why strlen is called pure function?
Each time you call the strlen() function with the same parameters, it always gives the same correct
answer. So, it is a pure function.
6. Differentiate pure and impure function.
Pure Function Impure Function
The return value of the pure functions solely The return value of the impure functions does not
depends on its arguments passed. solely depend on its arguments passed.
Hence, if you call the pure functions with the same Hence, if you call the impure functions with the
set of arguments, you will always get the same same set of arguments, you might get the different
return values. return values.
They do not have any side effects. They have side effects.
38. Using if .. else .. elif statement write a 39. Write the syntax of while loop.
suitable program to display largest of 3 Syntax:
numbers. while <condition>:
Program : statements block 1
a=int(input("Enter the first number:")) [else:
b=int(input("Enter the second number:")) statements block2]
c=int(input("Enter the third number:"))
if (a>b) and (a>c):
print(a, " is the largest number")
elif (b>c):
print(b, " is the largest number ")
else:
print(c, " is the largest number ")
40. List the differences between break and continue statements.
➢ The break statement terminates the loop when it is executed.
➢ Continue statement is used to skip the remaining part of a loop and start with next iteration.
..13.. A. Prabhakar - 9442979144
100% 12 – Computer Science
LESSON 7 - PYTHON FUNCTIONS
41. What is function?
Functions are named blocks of code that are designed to do specific job.
42. Write the different types of function.
❖ User-defined Functions ❖ Lambda Functions
❖ Built-in Functions ❖ Recursion Functions
43. What are the main advantages of function?
➢ It avoids repetition and makes high degree of code reusing.
➢ It provides better modularity for your application.
44. What is meant by scope of variable? Mention its types.
➢ Scope of variable refers to the part of the program, where it is accessible.
➢ i) local scope and ii) global scope are two types of scopes.
45. Define global scope.
A variable, with global scope can be used anywhere in the program. It can be created by defining a
variable outside the scope of any function/block.
46. Write the rules of local variable.
❖ A variable with local scope can be accessed only within the function/block that it is created in.
❖ When a variable is created inside the function/block, the variable becomes local to it.
❖ A local variable only exists while the function is executing.
❖ The format arguments are also local to function.
47. Write the basic rules for global keyword in python.
The basic rules for global keyword in Python are:
❖ When we define a variable outside a function, it’s global by default. You don’t have to use global
keyword.
❖ We use global keyword to read and write a global variable inside a function.
❖ Use of global keyword outside a function has no effect.
48. Differentiate ceil() and floor() function?
floor(): ceil():
It returns the largest integer less than or equal It returns the smallest integer greater than or
to x. equal to x.
Syntax: Syntax:
math.floor(x) math.ceil(x)
Example: Example:
x = 26.7 x = 26.7
print(math.floor(x)) print(math.ceil(x))
Output: Output:
26 27
49. Write a Python code to check whether a given year is leap year or not.
n=int(input("Enter a Year : "))
if n%4 == 0:
print(n," is a Leap Year")
else:
print(n," is not a Leap Year")
50. What is composition in functions?
The value returned by a function may be used as an argument for another function in a nested manner.
This is called composition.
BUILT-IN
GLOBAL
ENCLOSED
LOCAL
Local scope:
➢ Local scope refers to variables defined in current function.
➢ Always, a function will first look up for a variable name in its local scope. Only if it does not find it there,
the outer scopes are checked.
If you search for the number 25, the index will return to 3. If the searchable number is not in the array,
for example, if you search for the number 70, it will return -1.
LESSON 5 - PYTHON – VARIABLES AND OPERATORS
6. Explain input() and print() functions with examples.
input( ) function:
In Python, input( ) function is used to accept data as input at run time.
The syntax is,
Variable = input (“prompt string”)
✓ Where, prompt string is a statement or message to the user, to know what input can be given.
Example 1: input( ) with prompt string
>>> city=input (“Enter Your City: ”)
Enter Your City: Madurai
✓ If prompt string is not given in input( ) no message is displayed on the screen, thus, the user will not
know what is to be typed as input.
Example 2:input( ) without prompt string
>>> city=input()
Rajarajan
>>> print (“I am from”, city)
I am from Rajarajan
Note that in the above example, the user will not know what is to be typed as input.
❖ input() accepts all data as string or characters but not as numbers. The int( ) function is used to
convert string data as integer data explicitly.
print() function:
❖ In Python, the print() function is used to display result on the screen.
❖ It displays an entire statement which is specified within print ( ).
The syntax is,
print( “String’’ )
print( “string”, variable )
Examples:
(1) >>>print(“Welcome’’)
Welcome
(2) >>>x = 5
>>>print( “The value of x = ”,x)
The value of x = 5
7. Discuss in detail about Tokens in Python.
Tokens:
❖ Python breaks each logical line into a sequence of elementary lexical components known as Tokens.
❖ The normal token types are 1) Identifiers 2) Keywords 3) Operators 4) Delimiters and 5) Literals.
❖ Whitespace separation is necessary between tokens.
Doctor Patient
Diagnosis
5. Object Model:
➢ Object model stores the data in the form of objects, attributes and methods, classes and Inheritance.
➢ This model handles more complex applications, such as Geographic information System (GIS),
scientific experiments, engineering design and manufacturing.
➢ It is used in file Management System.
➢ It represents real world objects, attributes and behaviours.
Example:
Shape
get_area()
get_perimeter(
)
where,
✓ Shape is the class.
✓ Circle, Rectangle and Triangle are objects of class Shape.
✓ radius, length, breadth, base and height are attributes.
✓ get_area() and get_perimeter() are the methods.
➢ One row in a table is linked with only one row in another Vignesh 1002
table and vice versa.
Anand 1003
For example:
A student can have only one exam number.
Staff
2. One-to-Many Relationship: Department
For example:
Comput Anand
One Department has many staff members. er
Raj
a
3. Many-to-One Relationship:
Staff Department
➢ In Many-to-One Relationship, many entities can be related
with only one in the other entity.
➢ Multiple rows in staff members table is related with only one Rifaya Maths
Book Student
4. Many-to-Many Relationship:
➢ A many-to-many relationship occurs when multiple records in
a table are associated with multiple records in another table. Python Sumitha
For example:
Many Books in a Library are issued to many students. SQL Jino
C++ Anbu
➢ Home Button → The Home Button will help to return back to the original view.
➢ Forward/Back buttons → These buttons can be used to move back to the previous point you were at,
or forward again.
➢ Pan Axis → This cross-looking button allows you to click it, and then click and drag your graph around.
➢ Zoom → The Zoom button lets you click on it, then click and drag a square that you would like to zoom
into specifically. Zooming in will require a left click and drag. You can alternatively zoom out with a right
click and drag.
➢ Configure Subplots → This button allows you to configure various spacing options with your figure and
plot.
➢ Save Figure → This button will allow you to save your figure in various forms.
27. Explain the purpose of the following functions:
a. plt.xlabel
It is used to assign label for X-axis.
b. plt.ylabel
It is used to assign label for Y-axis.
c. plt.title
It is used to assign title for the chart.
d. plt.legend()
It is used to add legend for the data plotted. It is needed when more data are plotted in
the chart.
e. plt.show()
It is used to display our plot.
வாழ்த்துகளுடன்
அருணா பப்ளிககஷன்ஸ்