0% found this document useful (0 votes)
4 views5 pages

Class12 CS Combined Revision Notes

The document provides comprehensive revision notes for Class 12 Computer Science, focusing on Python basics, data structures, and functions. It covers topics such as keywords, data types, operators, loops, and built-in functions, along with detailed explanations of functions, parameters, and recursion. The notes emphasize practical coding tips and understanding the differences between mutable and immutable types.

Uploaded by

haruvijay4
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)
4 views5 pages

Class12 CS Combined Revision Notes

The document provides comprehensive revision notes for Class 12 Computer Science, focusing on Python basics, data structures, and functions. It covers topics such as keywords, data types, operators, loops, and built-in functions, along with detailed explanations of functions, parameters, and recursion. The notes emphasize practical coding tips and understanding the differences between mutable and immutable types.

Uploaded by

haruvijay4
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/ 5

Class 12 Computer Science - Combined Revision Notes

REVISION TOUR 1 - PYTHON BASICS

1. Introduction to Python
- Python is an interpreted, high-level programming language.
- It is dynamically typed and easy to read due to its simple syntax.

2. Keywords and Identifiers


- Keywords: Predefined reserved words (if, else, def, return, import, etc.)
- Identifiers: Names used to identify variables, functions, classes, etc.

3. Variables and Data Types


- Dynamic typing: No need to declare the type.
- Data Types: int, float, str, bool, list, tuple, dict, set

4. Operators
- Arithmetic: +, -, *, /, %, //, **
- Relational: ==, !=, <, >, <=, >=
- Logical: and, or, not
- Assignment: =, +=, -=, etc.

5. Input and Output


- input(): Reads a value from the user (always as a string)
- print(): Displays output

6. Conditional Statements
if condition:
# statements
elif condition:
# statements
else:
# statements

7. Loops
- for loop: Used for iterating over a sequence (list, string, etc.)
Example: for i in range(5): print(i)
- while loop: Repeats while condition is true.
- Loop Control: break (exit loop), continue (skip to next iteration), pass (do nothing)

8. Type Casting
- str(), int(), float(), list(), tuple() - convert from one type to another

REVISION TOUR 2 - PYTHON DATA STRUCTURES

1. Strings
- Sequence of characters; immutable.
- Common Methods: lower(), upper(), find(), replace(), split(), join(), strip()
- Slicing: str[start:stop:step]

2. Lists
- Ordered, mutable collection.
- Methods: append(), extend(), insert(), remove(), pop(), sort(), reverse()
- Indexing and slicing similar to strings

3. Tuples
- Ordered, immutable collection.
- Useful for fixed data (like coordinates, RGB colors)

4. Dictionaries
- Unordered, mutable collection of key-value pairs.
- Syntax: dict = {'name': 'Alice', 'age': 17}
- Methods: keys(), values(), items(), get(), update(), pop()

5. Sets
- Unordered, unindexed, no duplicate items.
- Useful for membership tests and set operations (union, intersection).

6. List Comprehension
- Compact way to create lists:
[x for x in range(10) if x % 2 == 0]

7. Useful Built-in Functions


- len(), type(), max(), min(), sum(), sorted(), id()
Tips:
- Practice tracing and writing code.
- Focus on syntax and indentation.
- Understand behavior of mutable vs immutable types.
- Try dry runs for loops and conditionals.

WORKING WITH FUNCTIONS - FULL NOTES

1. What is a Function?
- A function is a reusable block of code that performs a specific task.
- Helps reduce redundancy and makes code more readable.

2. Types of Functions
- Built-in Functions: Predefined (e.g., print(), len(), input(), type())
- User-defined Functions: Created by the programmer using def

3. Defining a Function
Syntax:
def function_name(parameters):
statements
return value

Example:
def greet(name):
print("Hello", name)

4. Calling a Function
- Just use the function name with arguments: greet("Haru")

5. Parameters and Arguments


- Parameters: variables listed in function definition
- Arguments: values passed during function call

6. Return Statement
- Used to return a value from a function
- Ends the execution of the function

Example:
def add(a, b):
return a + b

7. Default Parameters
- Parameters with default values
Example:
def greet(name="User"):
print("Hello", name)

8. Keyword and Positional Arguments


- Positional: matched by position
- Keyword: matched by name

Example:
def student(name, age): pass
student(age=17, name="Haru")

9. Variable Scope
- Local Scope: Defined inside function
- Global Scope: Defined outside function

global x
x=5
def show():
global x
x=x+1

10. Recursion
- Function that calls itself
- Must have a base condition to end recursion

Example:
def factorial(n):
if n == 1:
return 1
return n * factorial(n - 1)

11. Lambda Functions


- Small anonymous functions
Syntax: lambda arguments: expression

Example:
square = lambda x: x*x
print(square(5)) # Output: 25

Tips:
- Always trace recursive functions.
- Use return wisely.
- Know the difference between arguments and parameters.
- Use local/global properly.

You might also like