0% found this document useful (0 votes)
10 views12 pages

GATE Python Detailed Notes

This document provides a comprehensive overview of Python programming, covering its basics, data types, operators, control flow, functions, and more. Key concepts include the execution model, mutable vs immutable types, file handling, exception handling, and object-oriented programming principles. Advanced topics such as list comprehensions, generators, and decorators are also discussed.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views12 pages

GATE Python Detailed Notes

This document provides a comprehensive overview of Python programming, covering its basics, data types, operators, control flow, functions, and more. Key concepts include the execution model, mutable vs immutable types, file handling, exception handling, and object-oriented programming principles. Advanced topics such as list comprehensions, generators, and decorators are also discussed.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

GATE PYTHON – COMPLETE DETAILED SHORT

NOTES

1. Python Basics & Execution Model

Python is an interpreted, high-level, dynamically typed language. Code is executed line by line by
Python Interpreter.
Indentation defines blocks. Variables are references to objects.
Keywords: False, None, True, and, as, assert, break, class, continue, def, del, elif, else, except,
finally, for, from, global, if, import, in, is, lambda, nonlocal, not, or, pass, raise, return, try, while,
with, yield.
2. Data Types

int, float, complex (3+4j). Boolean: True/False.


Sequence: str, list, tuple. Set: set, frozenset. Mapping: dict.
Type casting: int(), float(), str(), list(), tuple().
Mutable: list, dict, set. Immutable: int, float, str, tuple.
3. Operators

Arithmetic: + - * / // % **
Relational: > < >= <= == !=
Logical: and or not
Bitwise: &, |, ^, ~, <<, >>
Membership: in, not in
Identity: is, is not
4. Control Flow

if-elif-else.
for loop iterates over iterable.
while loop executes till condition false.
break exits loop, continue skips iteration, pass is null statement.
5. Functions

def function_name(parameters):
return value
Default, keyword, variable-length (*args, **kwargs).
Lambda: lambda x: x*x
Recursion must have base case.
6. Strings

Immutable. Indexing & slicing supported.


Common methods: upper(), lower(), find(), replace(), split(), join(), strip().
7. Lists & Tuples

List is mutable, tuple immutable.


append(), extend(), insert(), pop(), remove(), sort().
8. Dictionary & Set

dict stores key:value.


Methods: keys(), values(), items(), get().
set stores unique elements.
9. File Handling

open(filename, mode).
Modes: r, w, a, rb, wb.
with open() ensures file close.
10. Exception Handling

try-except-else-finally.
Common exceptions: ZeroDivisionError, ValueError, TypeError.
11. OOP

class, object, __init__ constructor.


Inheritance, polymorphism, encapsulation.
12. Advanced Topics

List comprehension: [x*x for x in range(5)]


Generator: yield keyword.
Decorator modifies function behavior.
map(), filter(), reduce().

You might also like