Class 12 Python - Lessons (Basics to Intermediate)
Lesson 1: Input and Output in Python
print() - used to display something on the screen
Example:
print("Hello")
print("My name is", "Hari") - prints multiple values
input() - used to take user input
name = input("Enter your name: ")
age = int(input("Enter your age: "))
marks = float(input("Enter your marks: "))
Lesson 2: Variables and Data Types
Variables are containers for storing data values.
Examples:
name = "Hari" # string (text)
age = 17 # int (whole number)
marks = 92.5 # float (decimal)
is_passed = True # bool (True/False)
Rules for variables:
- Can't start with a number
- No spaces or special characters (except _)
Lesson 3: Operators in Python
1. Arithmetic Operators:
+ - * / // % **
2. Comparison Operators:
== != > < >= <=
3. Logical Operators:
and or not
Lesson 4: If-Else Conditions
if condition:
# do this
else:
# do this
Example:
age = 18
if age >= 18:
print("Adult")
else:
print("Minor")
elif is used for more than 2 choices.
Lesson 5: Loops in Python
1. for loop:
for i in range(1, 6):
print(i)
2. while loop:
i=1
while i <= 5:
print(i)
i += 1
Indentation: Always add 4 spaces or 1 tab inside if, else, for, while blocks.