Revision Sheet For Class 12 Computer Scienc
Revision Sheet For Class 12 Computer Scienc
Functions
Key Concepts
Data Types: int, float, str, bool, list, tuple, dict, etc.
Input/Output:
input() returns string input
Type Casting:
Example 1:
a=5
b=2
print(a // b, a % b)
A:
21
Example 2:
Q: Write a Python program to take a number as input and print its square.
A:
Defining Function:
def func_name(parameters):
# block
return result
Parameters vs Arguments:
Default Parameters:
def greet(name="User"):
print("Hi", name)
Return vs Print:
return sends data back to caller, print displays it on screen.
Example 1:
def greet():
print("Hello Python!")
greet()
Example 2:
Q: Write a function multiply(a, b=5) that returns the product of two numbers.
A:
print(multiply(4)) # Output: 20
Opening a file:
open(filename, mode)
Modes:
'r' = read
'a' = append
'r+' = read + write
Reading:
Writing: write("text")
Example 1:
You're well on track for success — stay consistent and practice smart!