Class 12 Computer Science: Revision Sheet
Topics: Revision Tour 1 & 2, Working with Functions
Revision Tour 1 & 2 - Python Recap
- Data Types: int, float, str, list, tuple, set, dict
- Control Structures: if-elif-else, loops (for, while)
- Operators: Arithmetic (+, -, *, /), Logical (and, or, not), Membership (in, not in)
- List Methods: append(), insert(), remove(), sort()
- Dictionary Methods: keys(), values(), items(), get(), update()
- Input/output: input(), print(), type casting
Working with Functions
- Function Syntax: def func_name(parameters):
- Types:
* No argument, no return
* With argument, no return
* With argument and return
- Parameters vs Arguments
- Default and Keyword Arguments
- Scope: Local vs Global variables
- Return statement: ends function execution and sends value back
- Use of recursion (if in syllabus)
Examples:
1. def add(a, b): return a + b
2. def greet(name="Student"): print("Hello", name)
Sample Practice Questions
1. Predict the output of the following:
def test(x):
x=x+2
return x
print(test(5))
2. Write a function to check if a number is prime.
3. What is the difference between local and global variables?
4. Define a function with default arguments.
5. Write a function to count vowels in a string.