Computer science class 12, Schemes and Mind Maps of Computer science

Practice paper for computer science student

Typology: Schemes and Mind Maps

2024/2025

Uploaded on 12/09/2024

sarika-sharma-4
sarika-sharma-4 🇮🇳

1 document

1 / 311

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
   ,
KENDRIYA VIDYALAYA SANGATHAN,

 
ERNAKULAM REGION
2022
-
23
Based on the latest CBSE Exam Pattern for the Session 2022-23
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Computer science class 12 and more Schemes and Mind Maps Computer science in PDF only on Docsity!

केÛġȣय ͪ वɮयालय संगठन ,

KENDRIYA VIDYALAYA SANGATHAN,

एना[ कुलम ¢ेğ

ERNAKULAM REGION

2022

23

Based on the latest CBSE Exam Pattern for the Session 2022-

CHIEF PATRON

Mr R Senthil Kumar

Deputy Commissioner

KVS RO Ernakulam

PATRON

Mrs Deepti Nair

Assistant Commissioner

KVS RO Ernakulam

PRINCIPAL IN-CHARGE

Mr Alex Jose

Principal I/C, K V Konni

CONTENT AND REVIEW

BY PGT COMPUTER SCIENCE OF ERNAKULAM REGION

 Mrs. VIDYA R PRABHU, K V NO.1 PALAKKAD (CO-ORDINATOR)

 Mr. SREEJITH T, K V NO.2 KASARAGOD

 Mrs. REENA P V, K V PAYYANUR

 Mrs. BINDHIYA N, K V KELTRON NAGAR

 Mrs. REKHA C, K V KANNUR

 Mrs. ANJANA K K, K V NO.2 CALICUT

 Mr. ARUN PRASANTH, K V KANJIKODE

 Mrs. LATHA RAMAKRISHNAN, KV NO2. KOCHI

 Mrs. SREELEKSHMI S, K V ADOOR (SHIFT 1)

 Mrs. LIJINA T, K V AKKULAM

 Mrs. HARIPRIYA NAIR KV PANGODE

INDEX

  • 1 REVIEW OF PYTHON 1- S.NO NAME OF THE CHAPTER/UNIT PAGE NOs
  • 2 FUNCTIONS 38-
  • 3 DATA FILE HANDLING 62-
  • 4 DATA STRUCTURE - STACK 104-
  • 5 COMPUTER NETWORKS 123-
  • 6 DATABASE MANAGEMENT SYSTEM 174-
  • 7 SAMPLE PAPER-1 (SOLVED) 223-
  • 8 SAMPLE PAPER-2 (SOLVED) 237-
  • 9 SAMPLE PAPER-3 (SOLVED) 253-
  • 10 SAMPLE PAPER-4 (UNSOLVED) 269-
  • 11 CBSE (21-22) QP AND ANSWER KEY TERM-1 278-
  • 12 CBSE (21-22) QP AND ANSWER KEY TERM-2 292-

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022- 23 1

REVIEW OF PYTHON

LET US REVISE THE CONCEPTS THAT WE LEARNED IN CLASS XI

Characteristics of Python:

  1. Python is Object-Oriented Python supports concepts such as polymorphism, operator overloading and multiple inheritance.
  2. Indentation Indentation is one of the greatest features in python – indentation identifies the blocks of code.
  3. Open source Programming Language Python is an open source programming language. It can be freely downloaded. Installing python is free and easy
  4. It’s Powerful  Dynamic typing  Built-in types and tools  Library utilities  Third party utilities (e.g. NumPy, SciPy)  Automatic memory management
  5. It’s Portable and Platform independent  Python runs virtually in every major platform used today  As long as you have a compatible python interpreter installed, python programs will run in exactly the same manner, irrespective of platform.
  6. It’s easy to use and learn  No intermediate compiler  Python Programs are compiled automatically to an intermediate form called byte code, which the interpreter then reads.  This gives python the development speed of an interpreter without the performance loss inherent in purely interpreted languages.  Structure and syntax are pretty intuitive and easy to grasp.
  7. Interpreted Language Python is processed at runtime by python Interpreter
  8. Interactive Programming Language Users can interact with the python interpreter directly for writing the programs
  9. Straight forward syntax The formation of python syntax is simple and straight forward which also makes it popular.

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022- 23 3

The data stored in memory can be of many types. For example, a student roll number is stored as a numeric value and his or her address is stored as alphanumeric characters. Python has various standard data types that are used to define the operations possible on them and the storage method for each of them. Some are mutable and some are immutable.

 Numeric Types: int, float, complex  Boolean – True or False values. Used when comparisons are made and the result can be expressed as True or False  None – a special type with an unidentified value or absence of value.  Sequence: an ordered collection of elements. String, List and Tuples are sequences. Items/elements are Identified by its index.  Sets – an unordered collection of any type without duplicate entry.  Mappings – Dictionaries are mappings. Elements of dictionaries are key-value pairs. Keys are used to access values. Keys are immutable.

Based on the data type of a variable, the interpreter allocates memory and decides what can be stored in the reserved memory. Therefore, by assigning different data types to variables, you can store integers, decimals or characters in these variables.

Mutable and Immutable types:

If the values can be changed after creating the variable and assigning values, then it is called mutable. If the value assigned cannot be changed after creating and initializing it, then it is known as Immutable. When an attempt is made to update the immutable type, a new memory location is used with name remaining the same.

Assigning Values to Variables:

Python variables do not need explicit declaration to reserve memory space. The declaration happens automatically when you assign a value to a variable. The assignment operator (=) is used to assign values to variables. The operand to the left of the = operator is the name of the variable and the operand to the right of the = operator is the value stored in the variable. For example – a= 100 #an integer is signed b = 1000.0 # A floating point value c = "John" # A string d = ‘’’ Hello world good morning’’’ # multi line string

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022- 23 4

Multiple Assignments:

Python allows you to assign a single value to several variables simultaneously.

For example: a = b = c = 1 Here, an integer object is created with the value 1, and all three variables are assigned to the same memory location. You can also assign multiple objects to multiple variables.

For example − a,b,c = 1,2,"kvsch“ Here, two integer objects with values 1 and 2 are assigned to variables a and b respectively, and one string object with the value "john" is assigned to the variable c. Also, it is possible to define and initialize multiple variables with different values as given below a, b, c = 5,10, The above instruction will create three variables named a,b,c and initialize them with values 5, 10 20 respectively.

Output Variables:

The Python print statement is often used to output variables.Variables do not need to be declared with any particular type. Different type of data can be assigned even after initializing them with some type of data. x = 5 # x is of type int x = "kve " # x is now of type str print(x) Output: kve

To combine both text and a variable, Python uses the “+” character: Example x = "awesome" print("Python is " + x) Output of the above code is: Python is awesome

You can also use the + character to add a variable to another variable: Example x = "Python is " y = "awesome" z = x + y print(z) Output: Python is awesome

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022- 23 6

Binary right shift >>

and &

or \

Less than <

Greater than >

Less than or equal to <=

Greater than or equal to >=

Check equality ==

Check not equal !=

Statements:

A statement is an instruction that the Python interpreter can execute. We have normally two basic statements, the assignment statement and the print statement. Some other kinds of statements that are if statements, while statements, and for statements generally called as control flows.

Examples: An assignment statement creates new variables and gives them values:

>>> x= >>> school="kve"

A ‘print’ statement is to display something on the screen/monitor. We use the print()

function for this purpose. And input() function is used to receive the input from the user

through the keyboard.

Precedence of Operators:

Operator precedence affects how an expression is evaluated. Each operator is having a priority when used in an expression in combination with other operators. For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has higher precedence than +, so it first multiplies 32 and then adds into 7. Example 1: >>> 3+42 11 Multiplication gets evaluated before the addition operation

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022- 23 7

Parentheses () overriding the precedence of the arithmetic operators

Example 2: a = 20 b = 10 c = 15 d = 5 e = 0

e = (a + b) * c / d #( 30 * 15 ) / 5 print("Value of (a + b) * c / d is ", e) e = ((a + b) * c) / d # (30 * 15 ) / 5 print("Value of ((a + b) * c) / d is ", e) e = (a + b) * (c / d) # (30) * (15/5) print("Value of (a + b) * (c / d) is ", e)

e = a + (b * c) / d; # 20 +(150/5) print("Value of a + (b * c) /d is", e)

Output: Value of (a + b) * c / d is 90. Value of ((a + b) * c) / d is 90. Value of (a + b) * (c / d) is 90. Value of a + (b * c) /d is 50.

Comments:

Comments are discarded by the Python interpreter. Comments acts as some message to the Programmer. It can be used as documents.

Single-line comments begins with a hash(#) symbol and is useful in mentioning that the whole line should be considered as a comment until the end of line. A Multi line comment is useful when we need to comment on many lines. In python, triple double quote(“ “ “) and single quote(‘ ‘ ‘)are used for multi-line commenting. Example:

this is a single line comment

‘’’ I am a multi line comment’’’

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022- 23 9

Value Error: In Python, a value is the information that is stored within a certain object. To encounter a ValueError in Python means that is a problem with the content of the object you tried to assign the value to.

Python has many built-in exceptions which forces your program to output an error when something in it goes wrong. In Python, users can define such exceptions by creating a new class. This exception class has to be derived, either directly or indirectly, from Exception class. Different types of exceptions:  ArrayIndexOutOfBoundException.  ClassNotFoundException.  FileNotFoundException.  IOException.  InterruptedException.  NoSuchFieldException.  NoSuchMethodException

Modules:

Python module can be defined as a python program file which contains a python code including python functions, class, or variables. In other words, we can say that our python code file saved with the extension (.py) is treated as the module. We may have a runnable code inside the python module. A module in Python provides us the flexibility to organize the code in a logical way. To use the functionality of one module into another, we must have to import the specific module.

Syntax: import Every module has its own functions, those can be accessed with. (dot) Note: In python we have help ()

Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". Some of the modules like os, date, and calendar so on……

>>> import sys >>> print (sys.version) 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)]

>>> print(sys.version_info)

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022- 23 10

sys.version_info(major=3, minor=8, micro=0, release level='final', serial=0)

>>> print(calendar.isleap(2020)) True >>> print(calendar.isleap(2017)) False

Control Structures

Flow of execution means the way in which the instructions are executed. It can be

  1. Sequential execution
  2. Selection/ Conditional statements
  3. Iterations/loop Sequential execution means executing the statements one by one starting from the first instruction onwards.

Selection:

Selection or Conditional statements helps us to execute some statements based on whether the condition is evaluated to True or False.

Use of if statement: The if statement contains a logical expression using which data is compared and a decision is made based on the result of the comparison.

Syntax: if : statement(s)

If the boolean expression evaluates to TRUE, then the block of statement(s) inside the if statement is executed. If boolean expression evaluates to FALSE, then the first set of code after the end of the if statement(s) is executed.

Flow chart representing the execution of ‘if’ statement:

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022- 23 12

Flow Chart:

Example of if - else: a=int(input('enter the number')) if a>5: print("a is greater") else: print("a is smaller than the input given") Output: enter the number 2 a is smaller than the input given

a=10 b= if a>b: print("A is Greater than B") else: print("B is Greater than A")

Output: B is Greater than A

Chained Conditional: (If-elif-else):

The elif statement allows us to check multiple expressions for TRUE and execute a block of code as soon as one of the conditions evaluates to TRUE. Similar to the else, the elif statement is optional. However, unlike else, for which there can be at most one statement, there can be an arbitrary number of elif statements following an if.

KVS RO EKM - STUDENT SUPPORT MATERIAL (COMPUTER SCIENCE-083) FOR THE ACADEMIC YEAR 2022- 23 13

Syntax of if – elif - else : If : Body of if stmts elif < test expression>: Body of elif stmts else: Body of else stmts

Flow Chart:

Example of if - elif – else: a=int(input('enter the number')) b=int(input('enter the number')) c=int(input('enter the number')) if a>b: print("a is greater") elif b>c: print("b is greater") else: print("c is greater") Output: enter the number 5 enter the number 2 enter the number 9 a is greater >>> enter the number 2