■ Basics of Python and Even/Odd Program
1. Introduction to Python
Python is a high-level, interpreted programming language. It is popular in Data Science, Web
Development, AI, and Automation. It is simple, versatile, and has vast library support.
print("Hello, Python!")
Easy Portable
Python
Open Source Libraries
2. Variables & Data Types
Variables are containers for storing values. Python detects data types automatically.
Type Example
int 10, -45
float 3.14, -2.5
str "hello"
bool True, False
age = 18
pi = 3.14
name = "Tanishka"
is_student = True
3. Input & Output
Python uses print() for output and input() for input.
name = input("Enter your name: ")
print("Welcome,", name)
■ Tip: input() always returns string, use int() or float() for numeric input.
4. Operators
Type Operators
Arithmetic +, -, *, /, //, %, **
Comparison ==, !=, >, <, >=, <=
Logical and, or, not
Assignment =, +=, -=, *=, /=, %=
Identity is, is not
Membership in, not in
5. Control Statements
Conditional statements decide the flow of execution.
n = 5
if n > 0:
print("Positive")
elif n == 0:
print("Zero")
else:
print("Negative")
Start
n > 0?
Yes No
Positive Zero/Neg
6. Even/Odd Program
A number is even if divisible by 2, otherwise odd.
n = int(input("Enter number: "))
if n % 2 == 0:
print("Even")
else:
print("Odd")
■ Sample Run: Input → 10 Output → Even
Start
n % 2 == 0?
Yes No
Even Odd
■ Exam Tip: Always write condition clearly (n % 2 == 0).
7. Extra Practice Questions
Similar programs often asked in exams:
- Check Prime number
- Factorial of a number
- Palindrome string/number
- Largest of three numbers
8. Quick Revision Summary
Topic Key Point
Variables No declaration needed
Input input() always string
Operators Arithmetic, Logical, Comparison, etc.
Control if, elif, else
Even/Odd Check remainder with % 2