Complete Exam-Focused Study Notes
Beginner Level • Important Definitions • Syntax • Examples • Quick Revision
Fundamental Python concepts: features, data types, operators, control statements, loops, functions and commonly tested programs.
1. Introduction to Python
Definition: Python is a high-level, interpreted, general-purpose programming language known for simple, readable syntax.
• Developer: Guido van Rossum • First released: 1991 • Extension: .py
• Features: simple, interpreted, portable, open-source, object-oriented, dynamically typed, extensive libraries.
Important Definitions
Term Definition
Program Set of instructions to perform a task.
Algorithm Step-by-step procedure to solve a problem.
Flowchart Graphical representation of an algorithm.
Syntax Rules for writing valid code.
Variable A name that refers to a value.
Keyword Reserved word with a predefined meaning.
Identifier Name used for variables, functions, classes, etc.
Expression Values, variables and operators producing a result.
Statement An instruction executed by a program.
Comment Text ignored during execution; explains code.
2. Variables and Identifiers
A variable is a name that refers to a value. Python does not require explicit type declarations.
name = "Aman"
age = 17
x = 10
x = "Hello"
• Start identifiers with a letter or underscore (_), not a digit.
• May contain letters, digits and underscores; no spaces or special symbols.
• Cannot be a keyword; identifiers are case-sensitive (age ≠ Age).
• Valid: student_name, _total, marks1. Invalid: 1name, student name, class.
3. Data Types
Type Meaning Example
int Integer 10, -5
float Decimal 3.14
complex Complex number 2+3j
bool Boolean True
str Text 'Python'
list Ordered, mutable [1, 2]
tuple Ordered, immutable (1, 2)
set Unique elements {1, 2}
dict Key-value pairs {'a': 1}
NoneType No value None
Mutable: list, set, dictionary. Immutable: int, float, string, tuple, Boolean.
Python Programming • Exam Notes Page 1
, 4. Input, Output & Type Conversion
Output — print()
print("Hello World")
print(10 + 5) # 15
Input — input()
input() accepts user input and returns a string by default.
name = input("Enter name: ")
age = int(input("Enter age: "))
marks = float(input("Enter marks: "))
Type conversion
int() → integer • float() → float • str() → string • bool() → Boolean • list() → list • tuple() → tuple.
x = "10"
print(int(x) + 5) # 15
5. Operators
Category Operators / Meaning
Arithmetic + add; − subtract; * multiply; / true division; // floor division; % remainder; ** power
Comparison ==, !=, >, <, >=, <= (return True/False)
Logical and: both true; or: at least one true; not: reverses truth value
Assignment =, +=, -=, *=, /=, //=, %=, **=
Membership in, not in — membership test
Identity is, is not — same object reference
Examples: 5/2 = 2.5; 5//2 = 2; 5%2 = 1; 2**3 = 8.
6. Conditional Statements
Used to make decisions based on conditions.
if / if-else / if-elif-else
if n % 2 == 0:
print("Even")
else:
print("Odd")
if marks >= 90:
print("A")
elif marks >= 60:
print("B")
else:
print("C")
Rule: Use a colon (:) and indent the statements inside each block.
7. Loops
for loop and range()
for i in range(1, 6):
print(i) # 1 to 5
range(stop) starts at 0; stop excluded. range(start, stop) excludes stop. range(start, stop, step) uses step. Example: range(1,
10, 2) → 1, 3, 5, 7, 9.
while loop
i = 1
while i <= 5:
print(i)
i += 1
Statement Purpose
break Terminates nearest enclosing loop.
continue Skips rest of current iteration.
pass Does nothing; placeholder.
Python Programming • Exam Notes Page 2