0% found this document useful (0 votes)
18 views2 pages

Python Revision Class12

This document provides a revision guide for Python data structures including lists, strings, tuples, and dictionaries, highlighting their characteristics and common methods. It also lists built-in functions useful for data manipulation. Each section includes examples of how to perform operations on these data types.
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)
18 views2 pages

Python Revision Class12

This document provides a revision guide for Python data structures including lists, strings, tuples, and dictionaries, highlighting their characteristics and common methods. It also lists built-in functions useful for data manipulation. Each section includes examples of how to perform operations on these data types.
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

Python Revision: Class 12 CS (CBSE)

LISTS (Mutable, Ordered)

- len(list): Number of elements


- [Link](x): Add x at end
- [Link](i, x): Insert x at index i
- [Link](x): Remove first x
- [Link](): Remove last element
- [Link](i): Remove at index i
- [Link](): Sort in ascending order
- [Link](): Reverse in place
- [Link](x): Index of x
- [Link](x): Count of x
- del list[i]: Delete element at index i
- [Link](): Empty the list

STRINGS (Immutable, Ordered)

- len(s): Length of string


- [Link](), [Link](), [Link]()
- [Link](): Remove spaces
- [Link]('x'): Index of 'x'
- [Link]('x'): Count 'x'
- [Link]('a','b'): Replace a with b
- [Link]('H'), [Link]('o')
- [Link](): Split at spaces
- ' '.join(list): Join list into string

TUPLES (Immutable, Ordered)

- len(t): Length
- [Link](x): Index of x
- [Link](x): Count of x
- list(t): Convert to list
- tuple(list): Convert to tuple

DICTIONARIES (Mutable, Key-Value)

- len(d): Number of items


- [Link](), [Link](), [Link]()
- [Link]('key'): Safe access
- d['key']: Direct access
- d['key'] = value: Add/update key
- [Link]('key'): Remove key
- [Link]({'k':v}): Add/update multiple
- [Link](): Empty dictionary

COMMON BUILT-IN FUNCTIONS


Python Revision: Class 12 CS (CBSE)
- type(x), id(x): Type and memory
- max(list), min(list), sum(list)
- sorted(list): New sorted list
- range(n): 0 to n-1
- enumerate(list): Index with value
- zip(list1, list2): Pairwise tuples

You might also like