Class 11 Computer Science
Chapter 3: Brief Overview of Python / Getting Started with Python
Comprehensive Revision Notes CBSE / NCERT Aligned
Core Concept: Python is a high-level, interpreted, interactive, object-oriented programming language
designed for readability, clean syntax, and rapid application development across data science, web
applications, and system automation.
1. Introduction & Features of Python
Created by Guido van Rossum and released in 1991, Python follows an expressive philosophy emphasizing code
readability and simplicity.
Key Features:
• High-Level & Interpreted: Python code is executed line-by-line by the Python Interpreter, eliminating explicit
compilation steps for developers.
• Easy to Read & Learn: Clean syntax using indentation instead of curly braces {} or explicit end statements.
• Dynamically Typed: Variables do not require explicit type declarations. Variable types are determined
automatically at runtime based on assigned values.
• Extensive Standard Library: Provides built-in modules for math, file handling, regular expressions, and
networking ("Batteries Included").
• Cross-Platform & Portable: Python code runs seamlessly across Windows, macOS, Linux, and Unix without
modification.
• Free & Open Source: Maintained by the Python Software Foundation (PSF).
2. Python Execution Modes
Python provides two primary execution modes for interacting with code:
EXECUTION
DESCRIPTION PROS / BEST USED FOR LIMITATIONS
MODE
Ideal for quick testing, Code is not saved
Uses the Python Shell prompt
Interactive experimenting with functions, automatically; disappears
( >>> ). Executes instructions
Mode and debugging small after closing the interactive
immediately line-by-line.
snippets. terminal window.
Write code in a file saved with Essential for developing
Requires saving and running
a .py extension and complete applications,
Script Mode the file every time code
execute the complete file reusable functions, and large
modifications occur.
together. programs.
Page 1 of 4
3. Python Character Set & Language Tokens
A Token is the smallest individual unit in a Python program. Python programs are built using five main types of
tokens:
A. Keywords
Reserved words that carry predefined, special meanings to the Python interpreter. Keywords cannot be used as
variable names or identifiers.
Examples (35 total in Python 3.x): False , True , None , and , or , not , if , elif , else , for , while ,
break , continue , def , return , import , class , is , in .
Note: Capitalization of Keywords
Only three Python keywords start with capital letters: True , False , and None . All other keywords are
strictly in lowercase.
B. Identifiers (Variable Names)
User-defined names given to variables, functions, classes, or modules to identify them uniquely.
Rules for Naming Identifiers:
• Must begin with a letter (A-Z, a-z) or an underscore ( _ ).
• Can contain letters, digits (0-9), and underscores.
• Cannot start with a digit (e.g., 1st_num is invalid).
• Case-sensitive: Total , total , and TOTAL are three distinct identifiers.
• Cannot use Python reserved keywords.
• No special characters or punctuation marks permitted (e.g., @ , $ , % , - , spaces).
VALID IDENTIFIERS INVALID IDENTIFIERS REASON FOR INVALIDITY
_count 2nd_val Starts with a digit
student_name user-name Hyphen - is not allowed
totalMarks100 class Reserved Python keyword
AVG_PRICE net pay Space not allowed inside identifiers
C. Literals (Data Values)
Constant, fixed values directly stored in variables or evaluated inside expressions:
• Numeric Literals:
◦ Integer: Whole numbers without fractions (e.g., 10 , -45 , 0 ).
◦ Float: Decimal / real values (e.g., 3.14 , -0.005 , 1.5e3 ).
◦ Complex: Numbers with real and imaginary parts (e.g., 3 + 5j ).
Page 2 of 4
• String Literals: Character sequences enclosed in single quotes ( '...' ), double quotes ( "..." ), or triple
quotes ( '''...''' for multiline strings).
• Boolean Literals: Represents logical values True or False .
• Special Literal: None (represents absence of value or null status).
D. Operators
Symbols that trigger computation or logical evaluation on operands:
OPERATOR CATEGORY SYMBOLS EXAMPLES & BEHAVIOR
7 / 2 → 3.5 (Float Div)
7 // 2 → 3 (Floor Div)
Arithmetic + , - , * , / , % , ** , //
7 % 2 → 1 (Modulus/Remainder)
2 ** 3 → 8 (Exponentiation)
Compares values and returns True or False .
Relational (Comparison) == , != , > , < , >= , <=
5 > 3 → True
Combines conditional expressions.
Logical and , or , not
(5 > 2) and (3 < 1) → False
Assigns/updates values.
Assignment = , += , -= , *= , /=
x += 5 equivalent to x = x + 5
'a' in 'apple' → True
Identity & Membership is , is not , in , not in
x is y checks memory identity.
E. Punctuators / Delimiters
Symbols used to organize sentence structures, expressions, lists, and function calls.
Examples: ( ) , [ ] , { } , , , : , . , ; , = .
4. Structure of a Python Program & Rules
# Program: Calculate Simple Interest
# Author: Class 11 Student
def calculate_interest(p, r, t):
interest = (p * r * t) / 100 # Formula computation
return interest
# Main Execution Block
principal = 10000
rate = 7.5
time = 2
result = calculate_interest(principal, rate, time)
print("Simple Interest =", result)
Page 3 of 4
Key Structural Elements:
• Comments: Non-executable notes ignored by interpreter. Single-line comments start with # . Inline comments
placed after code.
• Docstrings: Multiline strings enclosed in triple quotes ( """...""" ) placed directly under function/class
headers to provide internal documentation.
• Statements: Instructions that the Python interpreter can execute.
• Expressions: Any valid combination of variables, constants, and operators that evaluates to a value (e.g., (p *
r * t) / 100 ).
• Indentation: Python uses leading spaces (typically 4 spaces) instead of curly braces to define code blocks
(functions, loops, conditionals). Improper indentation raises an IndentationError .
5. Input and Output Operations
Input using input() Function
The input() function captures user input from the console. Important: It always returns input as a String (str)
datatype.
# Basic input capturing
name = input("Enter your name: ")
# Type casting to numerical types
age = int(input("Enter your age: "))
marks = float(input("Enter percentage: "))
Output using print() Function
Prints values to standard output device (monitor). Accepts optional control parameters:
• sep (Separator): Defines string placed between multiple printed items (Default is a space ' ' ).
• end (End marker): Defines character appended at the end of output line (Default is newline ' ' ).
print("Python", "Programming", sep=" - ", end="!\n")
# Output: Python - Programming!
Quick Revision Summary
• Interpreter: Executes code line-by-line; Script mode saves code in .py files.
• Tokens: Keywords, Identifiers, Literals, Operators, and Punctuators.
• Naming Rules: Identifier must start with letter/ _ , case-sensitive, no spaces or special symbols.
• Division Operators: / gives float result, // truncates to integer (floor), % yields remainder.
• Input Handling: input() always returns a string; requires explicit casting ( int() / float() ) for
numbers.
Page 4 of 4