I PU Python 50 Marks Package - Theory - UPDATED
Chapter 1:
Computer System
🔹 Data Transfer in
Computer System
- Data
moves between CPU, primary memory, and secondary memory using buses.
- Types
of buses:
- Data
Bus: Transfers actual data (bi‑directional).
- Address
Bus: Transfers memory addresses (uni‑directional).
- Control
Bus: Transfers control signals (uni‑directional).
- Memory
Controller: Manages flow of data into/out of main memory.
🔹 Data vs Information
- Data:
Raw, unorganized facts (not sufficient for decision‑making).
- Information:
Organized, contextual, meaningful data (sufficient for decision‑making).
🔹 Types of Data
- Structured
Data: Organized in predefined format (tables, databases).
- Unstructured
Data: No fixed format (audio, video, text docs, social media posts).
- Semi‑structured
Data: Loosely organized with tags/markers (XML, JSON, CSV, emails).
🔹 Data Handling
- Data
Capturing: Gathering data from sources (keyboard, sensors, social
media).
- Data
Storage: Saving data in files/databases; requires large servers in
organizations.
- Data
Retrieval: Fetching stored data for processing; speed is crucial.
- Data
Deletion & Recovery: Deleted data can sometimes be recovered if
not overwritten.
🔹 Microprocessors
- Definition:
CPU implemented on a single chip.
- Built
on integrated circuits with millions of transistors.
- Can
process millions of instructions per millisecond.
- Generations:
- 1st
(1971–73): 4/8 bit, Intel 8080.
- 2nd
(1974–78): 8 bit, Intel 8085.
- 3rd
(1979–80): 16 bit, Intel 8086.
- 4th
(1981–95): 32 bit, Intel 80386.
- 5th
(1995–present): 64 bit, multicore (Pentium, Xeon).
Specifications:
- Word
Size: Bits processed at a time (8, 16, 32, 64).
- Memory
Size: Max memory supported (up to exabytes today).
- Clock
Speed: Pulses per second (Hz → GHz).
- Cores:
Units inside CPU (dual‑core, quad‑core, octa‑core).
🔹 Microcontrollers
- Definition:
Small computing device with CPU, RAM, ROM, I/O ports on one chip.
- Used
for specific tasks (washing machines, remotes, microwaves).
- Automates
repetitive tasks without human intervention.
🔹 Programming Tools
- Low‑level
language: Machine language (0s and 1s), Assembly language.
- High‑level
language: Human‑readable (Python, C, C++).
- Language
Translators:
- Compiler:
Converts whole program at once.
- Interpreter:
Converts line by line.
- Assembler:
Converts assembly language to machine code.
- Program
Development Tools:
- Text
Editor: Write source code.
- IDE:
Integrated environment with editor, compiler, debugger.
🔹 Software
- Definition:
Set of instructions that operate hardware.
- Types:
- System
Software: OS, device drivers, utilities.
- Programming
Tools: Compilers, interpreters, IDEs.
- Application
Software: General purpose (MS Word, Photoshop) or customized (school
ERP).
- Software
Usage Types:
- Freeware,
Open Source, Proprietary, Shareware.
🔹 Operating System
Interfaces
- Command‑based:
Text commands (MS‑DOS, Unix).
- GUI:
Icons, menus (Windows, Mac).
- Touch‑based:
Smartphones, tablets.
- Voice‑based:
Siri, Cortana.
- Gesture‑based:
Gaming, medical devices.
🔹 Functions of Operating
System
- Process
Management: Handles multiple tasks.
- Memory
Management: Allocates/frees memory.
- File
Management: Creates, updates, deletes files.
- Device
Management: Controls I/O devices via drivers.
📖 Key Definitions (Exam‑Ready)
- Computer
System: Electronic device that processes data into information.
- Data
Bus: Bi‑directional bus carrying data between CPU and memory.
- Address
Bus: Uni‑directional bus carrying memory addresses.
- Control
Bus: Uni‑directional bus carrying control signals.
- Data:
Raw, unorganized facts.
- Information:
Organized, meaningful data.
- Structured
Data: Data stored in predefined format (tables).
- Unstructured
Data: Data without fixed format (audio, video, text).
- Semi‑structured
Data: Data with loose structure and tags (XML, JSON).
- Microprocessor:
CPU on a single chip performing arithmetic, logic, and control.
- Microcontroller:
CPU + memory + I/O on one chip for specific tasks.
- Compiler:
Translates entire program into machine code.
- Interpreter:
Translates one line at a time.
- Assembler:
Converts assembly language into machine code.
- System
Software: Software managing hardware (OS, drivers).
- Application
Software: Software for user tasks (Word, Photoshop).
- Operating
System (OS): Main system software managing hardware, memory, files,
and processes.
Chapter
4: Introduction to Problem Solving
🔹 Problem Solving Process
- Analyzing
the problem: Identify inputs, outputs, and core functionalities.
- Developing
an algorithm: Write step‑by‑step instructions in natural language.
- Coding:
Convert algorithm into program using high‑level language.
- Testing
& Debugging: Ensure correctness through unit, integration, system, and
acceptance testing.
🔹 Algorithm
- Definition:
A finite sequence of precise steps to solve a problem and produce output.
- Characteristics:
- Precision
– steps clearly defined.
- Uniqueness
– each step has a unique result.
- Finiteness
– must stop after finite steps.
- Input
– accepts data.
- Output
– produces result.
🔹 Representation of Algorithms
- Flowchart:
Visual diagram using symbols (terminator, process, decision, input/output,
arrows).
- Pseudocode:
Human‑readable, non‑formal description using keywords (INPUT, COMPUTE,
PRINT, IF/ELSE, WHILE).
🔹 Flow of Control
- Sequence:
Steps executed one after another.
- Selection:
Conditional branching (if‑else).
- Repetition:
Loops/iteration (while, for).
🔹 Verification of Algorithms
- Dry
Run: Simulate algorithm with sample inputs to check correctness.
- Helps
identify missing details or incorrect steps.
🔹 Comparison of Algorithms
- Time
Complexity: Processing time required.
- Space
Complexity: Memory required.
- Efficient
algorithms minimize both.
🔹 Coding
- Writing
algorithm in programming language (Python, C, C++).
- Source
code translated into machine code using compiler/interpreter.
- Syntax
rules must be followed.
🔹 Decomposition
- Breaking
complex problems into smaller sub‑problems.
- Each
sub‑problem solved separately, then integrated.
- Saves
time and effort, allows teamwork.
📖 Key Definitions (Exam‑Friendly)
- Problem
Solving: Identifying a problem, designing an algorithm, coding, and
testing/debugging.
- Algorithm:
Finite sequence of precise steps to achieve desired output.
- Flowchart:
Diagrammatic representation of algorithm using symbols and arrows.
- Pseudocode:
Human‑readable representation of algorithm, not executable by computer.
- Sequence:
Execution of steps one after another.
- Selection:
Conditional branching (if‑else).
- Repetition:
Looping through steps until condition is met.
- Dry
Run: Manual simulation of algorithm with sample inputs to verify
correctness.
- Time
Complexity: Measure of time taken by an algorithm.
- Space
Complexity: Measure of memory used by an algorithm.
- Decomposition:
Breaking a complex problem into smaller manageable sub‑problems.
🔹 Flowchart Symbols
|
Symbol |
Name |
Function |
|
Oval |
Start/End (Terminator) |
Indicates beginning or end of algorithm. |
|
Rectangle |
Process (Action) |
Represents a step or computation. |
|
Diamond |
Decision |
Represents a condition check (Yes/No, True/False). |
|
Parallelogram |
Input/Output |
Represents data input or output. |
|
Arrow |
Connector |
Shows direction/flow of control. |
🔹 Pseudocode Keywords
- INPUT
→ Accept data from user.
- OUTPUT
/ PRINT → Display result.
- COMPUTE
→ Perform calculation.
- IF
/ ELSE → Conditional branching.
- WHILE
/ FOR → Looping (repetition).
- TRUE
/ FALSE → Boolean values for decisions.
- INCREMENT
/ DECREMENT → Increase or decrease variable value.
- Always
start and end flowcharts with oval symbols.
- Use
decision diamonds for conditions (odd/even, age categories).
- Pseudocode
is not executable, but must be clear and logical.
- Keep
pseudocode indented and structured for readability.
Part A – Match the Pseudocode with
Flowchart Symbols
- INPUT
num → ?
- COMPUTE
sum = num1 + num2 → ?
- IF
num MOD 2 == 0 THEN → ?
- PRINT
result → ?
- Start
/ End → ?
Part B – Fill in the Blanks
- The
diamond symbol in a flowchart is used for __________.
- The
rectangle symbol represents __________.
- The
parallelogram symbol is used for __________.
- The
oval symbol indicates __________.
- The
arrow symbol shows __________.
✅ Answer Key
Part A
1 → Parallelogram (Input/Output)
2 → Rectangle (Process)
3 → Diamond (Decision)
4 → Parallelogram (Input/Output)
5 → Oval (Terminator)
Part B
- Decision
- Process/Action
- Input
or Output
- Start/End
- Flow
direction
✅
Sample 2/3/5 Answers
🔹 2 Marks Questions
- Algorithm:
A finite sequence of precise steps to solve a problem.
- Characteristics:
Precision, Finiteness. (1+1 marks)
- Flowchart
vs Pseudocode:
- Flowchart:
Visual diagram using symbols.
- Pseudocode:
Human‑readable text description. (1+1 marks)
- Dry
Run: Manual simulation of algorithm with sample inputs to verify
correctness.
- Importance:
Detects errors/missing steps before coding. (1+1 marks)
- Pseudocode
for square of a number:
- INPUT
num
- COMPUTE
square = num * num
- PRINT
square
5.
- Time:
Processing time taken by algorithm.
- Space:
Memory used by algorithm. (1+1 marks)
🔹 3 Marks Questions
- Steps
in problem solving:
- Analyze
problem (inputs/outputs).
- Develop
algorithm.
- Code
in programming language. (1+1+1 marks)
- Flowchart
for odd/even check:
- Input
number → Decision (num mod 2 == 0?) → Print “Even” / “Odd”. (Diagram +
explanation = 3 marks)
- Pseudocode
for rectangle area & perimeter:
INPUT length, breadth
COMPUTE Area = length * breadth
PRINT Area
COMPUTE Perim = 2 * (length +
breadth)
PRINT Perim
- Flow
of control types:
- Sequence:
Steps executed one after another.
- Selection:
Conditional branching (if‑else).
- Repetition:
Looping until condition met. (1+1+1 marks)
- Decomposition:
Breaking complex problem into smaller sub‑problems.
- Example:
Railway reservation system (train info, booking, billing). (2+1 marks)
🔹 5 Marks Questions
- Algorithm
& Flowchart for average of 5 numbers:
- Initialize
count=0, sum=0.
- Loop
5 times: Input number, add to sum, increment count.
- Compute
average = sum/5.
- Print
average. (Steps + diagram = 5 marks)
- Types
of software testing:
- Unit
testing: individual components.
- Integration
testing: combined modules.
- System
testing: whole system.
- Acceptance
testing: user requirements. (1+1+1+2 marks)
- Flowchart
vs Pseudocode comparison:
- Flowchart:
Visual, easy for non‑programmers, shows flow clearly.
- Pseudocode:
Textual, easier to modify, closer to coding.
- Both
useful; pseudocode better for programmers, flowchart better for non‑programmers.
(5 marks)
- Age
categorization pseudocode:
INPUT Age
IF Age < 13 THEN PRINT
"Child"
ELSE IF Age < 20 THEN PRINT
"Teenager"
ELSE PRINT "Adult"
- Dry
run example:
- Algorithm
to add times (hours + minutes).
- Input
T1=4h50m, T2=2h20m → initial result 6h70m (incorrect).
- Correction:
If minutes ≥ 60, add 1 hour and subtract 60 from minutes.
- Verified
result = 7h10m. (Explanation + correction = 5 marks)
Chapter
5: Getting Started with Python
🔹 Introduction to Python
·
Python: High‑level, interpreted, object‑oriented
programming language developed by Guido van Rossum (1991).
·
Owned by: Python Software Foundation
(PSF).
·
Features: Simple syntax, portable,
extensible, open‑source, supports multiple paradigms (procedural, object‑oriented).
·
Advantages: Easy to learn, large
libraries, cross‑platform.
·
Disadvantages: Slower than compiled
languages, not ideal for mobile apps.
🔹 Programming Language
Basics
·
Program: Ordered set of instructions
executed by computer.
·
Machine Language: 0s and 1s, hard for
humans.
·
High‑Level Languages: Python, C++, Java —
easier for humans but need translation.
·
Translators: Compiler (whole program),
Interpreter (line by line). Python uses interpreter.
🔹 Execution Modes:
o Interactive
Mode: Commands executed immediately (REPL).
o Script
Mode: Writing code in a file (.py) and running it.
🔹 First Program
·
Example:
·
print("Hello World")
·
Demonstrates Python’s simplicity and direct
execution.
🔹 Python Basics
·
Identifiers: Names for
variables/functions (must follow rules).
·
Keywords: Reserved words (e.g., if, else,
while, def).
·
Variables: Store values; dynamically
typed in Python.
·
Data Types: int, float, str, bool, list,
tuple, dict.
·
Operators: Arithmetic (+, -, *, /),
relational (==, !=, >), logical (and, or, not).
🔹 Input and Output
·
Input: input() function to take user
data.
·
Output: print() function to display
results.
🔹 Errors in Python
·
Syntax Errors: Violation of language
rules.
·
Runtime Errors: Errors during execution
(e.g., division by zero).
·
Logical Errors: Incorrect logic, wrong
output.
📖 Key Definitions (Exam‑Friendly)
·
Python: High‑level, interpreted
programming language.
·
Interpreter: Translates code line by
line.
·
Interactive Mode: Executes commands
immediately.
·
Script Mode: Executes code stored in a
file.
·
Identifier: Name given to
variables/functions.
·
Keyword: Reserved word with special
meaning.
·
Variable: Named storage for data.
·
Data Type: Classification of data (int,
float, str, etc.).
·
Operator: Symbol performing operations on
data.
·
Syntax Error: Mistake in code structure.
·
Runtime Error: Error during program
execution.
·
Logical Error: Wrong logic leading to
incorrect output.
List of 5 advantages and 5 disadvantages
of Python.
✅ Advantages of Python
1. Easy
to Learn & Readable – Simple syntax close to English, beginner‑friendly.
2. Interpreted
Language – Executes line by line, making debugging easier.
3. Cross‑Platform
– Runs on Windows, Linux, macOS without modification.
4. Large
Standard Library – Rich modules for web, data science, AI, networking, etc.
5. Supports
Multiple Paradigms – Procedural, object‑oriented, and functional
programming.
❌ Disadvantages of Python
1. Slower
Execution – Interpreted nature makes it slower than compiled languages like
C/C++.
2. High
Memory Usage – Not ideal for memory‑intensive tasks.
3. Weak
in Mobile Development – Limited use in mobile app programming.
4. Runtime
Errors – Dynamic typing can lead to unexpected bugs.
5. Database
Access Limitations – Less robust compared to languages like Java for
complex database applications.
📝 Rules for Identifiers
in Python
1. Allowed
Characters
o Identifiers
can contain letters (A–Z, a–z), digits (0–9), and underscore
(_).
2. Cannot
Start with a Digit
o Example:
123name ❌
o Correct:
name123 ✅
3. Case‑Sensitive
o Name,
name, and NAME are treated as different identifiers.
4. No
Special Characters
o Symbols
like @, $, %, #, ! are not allowed.
5. No
Keywords
o Reserved
words like if, else, while, class, def cannot be used as identifiers.
6. Underscore
Usage
o Identifiers
can start with _ (often used for private variables).
7. Length
o No
fixed length limit, but identifiers should be meaningful and readable.
✅ Examples
·
Valid: student_name, marks123, _value
·
Invalid: 123marks, student-name, if,
total$amount
Study from PDF material
Sample 2/3/5 Answers
🔹 2 Marks Questions
Q1.
List any two features of Python.
Ans:
·
Easy to learn and simple syntax.
·
Cross‑platform and portable.
Q2.
Difference between interactive mode and script mode in Python.
Ans:
·
Interactive Mode: Executes commands line by
line immediately (REPL).
·
Script Mode: Executes code written in a file
(.py)
Q3.
Define identifier and give two examples.
Ans:
·
Identifier: Name given to
variables/functions.
·
Examples: student_name, marks123.
(1+1 marks)
Q4.
Role of print() function.
Ans:
·
Displays output on the screen.
·
Example: print("Hello World").
🔹
3 Marks Questions
Q1.
Difference between compiler and interpreter (Python context).
Ans:
·
Compiler: Translates whole program at once.
·
Interpreter: Translates line by line.
·
Python uses interpreter.
(1+1+1 marks)
Q2.
Program to find square of a number.
num
= int(input("Enter a number: "))
square
= num * num
print("Square
=", square)
(Correct
logic + input + output = 3 marks)
Q3.
List three types of errors in Python with examples.
Ans:
·
Syntax Error: print "Hello" ❌
·
Runtime Error: Division by zero.
·
Logical Error: Wrong formula used.
(1+1+1 marks)
Q4.
Difference between keywords and identifiers.
Ans:
·
Keywords: Reserved words (e.g., if, else,
while).
·
Identifiers: User‑defined names (e.g., marks,
student_name).
·
Keywords cannot be used as identifiers.
(1+1+1 marks)
🔹
5 Marks Questions
Q1.
Program to accept two numbers and display sum, difference, product, quotient.
a
= int(input("Enter first number: "))
b
= int(input("Enter second number: "))
print("Sum =", a + b)
print("Difference
=", a - b)
print("Product
=", a * b)
print("Quotient
=", a / b)
(Input
+ operations + output = 5 marks)
Q2.
Five advantages and five disadvantages of Python.
Advantages: Easy syntax, interpreted, cross‑platform, large libraries, supports
multiple paradigms.
Disadvantages: Slower execution, high memory use, weak in mobile apps, runtime
errors due to dynamic typing, limited database support.
(5+5 points = 5 marks)
Q3.
Rules for identifiers in Python with examples.
Ans:
·
Can contain letters, digits, underscore.
·
Cannot start with digit.
·
Case‑sensitive.
·
No special characters.
·
Cannot use keywords.
·
Examples: Valid → student_name, Invalid →
123marks.
(Rules + examples = 5 marks)
Q4.
Program to calculate area and perimeter of rectangle.
length
= int(input("Enter length: "))
breadth
= int(input("Enter breadth: "))
area
= length * breadth
perimeter
= 2 * (length + breadth)
print("Area
=", area)
print("Perimeter
=", perimeter)
(Input
+ formula + output = 5 marks)
📘 Chapter 6 – Flow of Control (Summary)
🔹 Flow of Control
- Definition:
The order in which program statements are executed.
- Types
of control structures in Python:
- Selection
/ Decision / Branching
- Repetition
/ Looping / Iteration
1️⃣ Selection / Branching
if statement
- Syntax:
if condition:
statement(s)
- Example:
age = 18
if age >= 18:
print("Eligible to vote")
if‑else statement
- Syntax:
if condition:
statement(s)
else:
statement(s)
- Example:
age = 16
if age >= 18:
print("Eligible to vote")
else:
print("Not
eligible to vote")
if‑elif‑else statement
- Syntax:
if condition:
statement(s)
elif condition:
statement(s)
else:
statement(s)
- Example:
num = 0
if num > 0:
print("Positive")
elif num < 0:
print("Negative")
else:
print("Zero")
2️⃣ Indentation
- Definition:
Leading whitespace (spaces/tabs) groups statements into blocks.
- Syntax
Example:
if age >= 18:
print("Eligible") #
Block 1
else:
print("Not
eligible") # Block 2
3️⃣ Repetition / Looping
for loop
- Syntax:
for control_variable in sequence:
statement(s)
- Example:
for letter in "PYTHON":
print(letter)
while loop
- Syntax:
while condition:
statement(s)
- Example:
count = 1
while count <= 5:
print(count)
count += 1
4️⃣ range() Function
- Syntax:
range([start], stop[, step])
- Examples:
print(list(range(5))) # [0,1,2,3,4]
print(list(range(2,10))) # [2,3,4,5,6,7,8,9]
print(list(range(0,30,5))) # [0,5,10,15,20,25]
print(list(range(0,-5,-1))) # [0,-1,-2,-3,-4]
5️⃣ Loop Control Statements
break
- Syntax:
for i in range(5):
if i == 3:
break
print(i)
- Output:
0, 1, 2
continue
- Syntax:
for i in range(5):
if i == 2:
continue
print(i)
- Output:
0, 1, 3, 4
6️⃣ Nested Loops
Nested for loop
for i in range(2):
for j in range(2):
print(i, j)
Nested while loop
i = 1
while i <= 2:
j = 1
while j <= 2:
print(i, j)
j += 1
i += 1
✅ Quick Recap
- Selection:
if, if‑else, if‑elif‑else
- Indentation:
mandatory for blocks
- Loops:
for, while
- range():
generates integer sequences
- Control:
break (exit loop), continue (skip iteration)
- Nested
loops: loop inside another loop
✅
Sample 2/3/5 Answers
✨ Sample 2‑Mark Questions
- Q1.
What is flow of control in Python?
A: Flow of control is the order in which program statements are executed. It is managed using control structures like selection and looping. - Q2.
Name the two types of control structures in Python.
A: - Selection
/ Decision / Branching
- Repetition
/ Looping / Iteration
- Q3.
What is indentation in Python?
A: Indentation refers to leading whitespace at the beginning of a statement. Python uses indentation to group statements into blocks, and incorrect indentation causes errors.
✨ Sample 3‑Mark Questions
- Q1.
Differentiate between for loop and while loop.
A: - for
loop: Executes a block of code for a known number of iterations (over a
range or sequence).
- while
loop: Executes repeatedly until a condition becomes false.
- If
the condition is false initially, while loop body may not execute even
once.
- Q2.
Explain the use of break and continue statements with examples.
A: - break:
Exits the loop immediately.
Example: - for i in range(5):
- if i == 3:
- break
- print(i)
- continue:
Skips current iteration and moves to next.
Example: - for i in range(5):
- if i == 2:
- continue
- print(i)
- Q3.
Write the syntax of if‑elif‑else statement.
A: - if condition:
- statements
- elif condition:
- statements
- else:
- statements
✨ Sample 5‑Mark Questions
- Q1.
Explain the range() function with examples.
A: - range()
generates a sequence of integers.
- Syntax:
range([start], stop[, step])
- Examples:
- range(10)
→ [0,1,2,3,4,5,6,7,8,9]
- range(2,10)
→ [2,3,4,5,6,7,8,9]
- range(0,30,5)
→ [0,5,10,15,20,25]
- range(0,-9,-1)
→ [0,-1,-2,-3,-4,-5,-6,-7,-8]
- Q2.
Explain nested loops with examples.
A: - A
loop inside another loop is called a nested loop.
- Example
1: Nested for loop
- for i in range(2):
- for j in range(2):
- print(i, j)
- Example
2: Nested while loop
- i = 1
- while i <= 2:
- j = 1
- while j <= 2:
- print(i, j)
- j += 1
- i += 1
- Nested
loops can combine for and while.
- Q3.
Draw and explain the flowchart of a for loop.
A: - Steps:
1.
Start → Initialization
2.
Test expression
3.
If true → execute loop body → update control
variable
4.
Repeat until condition false
5.
Exit loop → execute following statements → Stop
📘 Python Exam – One Page Revision Notes
Chapter 1: Computer System
- Buses:
- Data Bus → Bi-directional (data transfer)
- Address Bus → Uni-directional (memory addresses)
- Control Bus → Uni-directional (control signals)
- Data vs Information:
- Data = raw facts; Information = processed, meaningful data
- Types of Data: Structured (tables), Unstructured (audio/video), Semi-structured (XML/JSON)
- Microprocessor: CPU on a chip; Generations → 1st (Intel 8080) → 5th (64-bit, multicore)
- Specifications: Word size, Memory size, Clock speed, Cores
- Microcontroller: CPU + RAM + ROM + I/O on one chip (used in appliances)
- Software Types: System (OS, drivers), Application (Word, Photoshop), Programming tools (compiler, IDE)
- OS Functions: Process, Memory, File, Device management
Chapter 4: Problem Solving
- Steps: Analyze → Algorithm → Code → Test/Debug
- Algorithm: Finite, precise steps → must have input & output
- Representations: Flowchart (symbols), Pseudocode (keywords: INPUT, PRINT, IF, WHILE)
- Flow of Control: Sequence, Selection (if-else), Repetition (loops)
- Verification: Dry run with sample inputs
- Complexity: Time (speed), Space (memory)
- Decomposition: Break big problems into smaller ones
Flowchart Symbols:
Oval = Start/End | Rectangle = Process | Diamond = Decision | Parallelogram = I/O | Arrow = Flow
Chapter 5: Python Basics
- Python: High-level, interpreted, object-oriented (1991, Guido van Rossum, PSF)
- Modes: Interactive (REPL), Script (.py file)
- Identifiers Rules: Letters, digits, underscore; not start with digit; case-sensitive; no keywords/special chars
- Data Types: int, float, str, bool, list, tuple, dict
- Operators: Arithmetic (+,-,*,/), Relational (==, !=, >), Logical (and, or, not)
- Errors: Syntax (rules), Runtime (execution), Logical (wrong logic)
- Advantages: Easy syntax, interpreted, cross-platform, large libraries, multiple paradigms
- Disadvantages: Slower, high memory use, weak in mobile apps, runtime bugs, limited DB support
Chapter 6: Flow of Control
- Selection:
- if → single condition
- if-else → two-way branching
- if-elif-else → multiple conditions
- Indentation: Mandatory for blocks
- Loops:
- for → known iterations
- while → until condition false
- range(): Generates integer sequences →
range(start, stop, step) - Loop Control:
- break → exit loop
- continue → skip iteration
- Nested Loops: Loop inside another loop
⚡ Quick Formulas & Programs
- Rectangle Area = length × breadth
- Rectangle Perimeter = 2 × (length + breadth)
- Average of 5 numbers = sum ÷ 5
- Odd/Even Check →
if num % 2 == 0
Sample Program (Sum, Difference, Product, Quotient):
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Sum =", a+b)
print("Difference =", a-b)
print("Product =", a*b)
print("Quotient =", a/b)
Python Syllabus Mind Map (Text-Based)
Computer System
[Computer
System]
|
-----------------------------------------------------------------
| | | |
[Buses] [Data Types] [Microprocessor] [Software]
| | | |
Data Bus Structured Generations 1–5 System (OS, Drivers)
Address Bus Unstructured Specs: Word size, Application (Word, Photoshop)
Control Bus Semi-structured Clock speed, Cores Programming Tools (Compiler, IDE)
| |
Data Handling (Capture, Store,
Retrieve, Delete) OS Functions
(Process, Memory, File, Device)
Problem Solving
[Problem
Solving]
|
-----------------------------------------------------------------
| | | |
[Algorithm] [Representation] [Flow of Control] [Verification]
| | | |
Characteristics Flowchart Symbols Sequence, Selection, Dry Run
Precision Pseudocode Repetition Complexity (Time/Space)
Finiteness INPUT/OUTPUT | Decomposition
Input/Output IF/ELSE, WHILE Example: Odd/Even
Python Basics
[Python Basics]
|
-----------------------------------------------------------------
| | | |
[Language] [Identifiers] [Errors] [Advantages/Disadvantages]
| | | |
High-level Rules: letters, Syntax Error + Easy syntax
Interpreted digits, _, no Runtime Error + Cross-platform
Modes: keywords, case Logical Error + Libraries
Interactive sensitive - Slower
Script - High memory
- Weak in mobile apps
Flow of Control in Python
[Flow of Control
in Python]
|
-----------------------------------------------------------------
| | | |
[Selection] [Indentation] [Loops] [Loop Control]
| | | |
if, if-else, Mandatory for for loop (known) break (exit loop)
if-elif-else blocks while loop (condition) continue (skip iteration)
range() function
Nested loops
Comments
Post a Comment