0% found this document useful (0 votes)
5 views

Python_Revision_Sheet

This document provides a quick revision sheet for Python, covering essential list, dictionary, and string methods, as well as data structures like tuples and sets. It also includes information on unpacking and float formatting. The methods and concepts are summarized with their respective functionalities for easy reference.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Python_Revision_Sheet

This document provides a quick revision sheet for Python, covering essential list, dictionary, and string methods, as well as data structures like tuples and sets. It also includes information on unpacking and float formatting. The methods and concepts are summarized with their respective functionalities for easy reference.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Quick Revision Sheet

List Methods:

- enumerate(iterable, start=0): Returns an enumerate object.

- append(value): Adds an item to the end of the list.

- pop(index): Removes and returns an item at the given index.

- insert(index, value): Inserts an element at the given index.

- remove(value): Removes the first occurrence of a value.

- sort(): Sorts the list in ascending order.

- reverse(): Reverses the list.

- extend(iterable): Extends the list by appending elements.

- index(value): Returns the index of the first occurrence.

- count(value): Counts occurrences of a value.

- copy(): Returns a shallow copy.

- clear(): Removes all items.

Dictionary Methods:

- dict = {}: Creates an empty dictionary.

- keys(), values(), items(): View dictionary elements.

- get(key, default): Returns value or default.

- update(dict2): Updates dictionary.

- pop(key), popitem(): Remove elements.

- copy(): Shallow copy.

- clear(): Remove all elements.

String Methods:

- capitalize(), count(substring), upper(), lower(), strip().


- replace(old, new), split(delimiter), join(iterable).

- ord(char), type(variable).

- String concatenation: "string" + variable + "string".

- Slicing: sliced = name[start:stop:step].

Data Structures:

- Tuple: Immutable, ordered.

- Set: Unique elements, unordered.

- add(), remove(), in, union(), difference(), intersection().

Unpacking:

- * (lists, tuples): print(*[1,2,3])

- ** (dicts as kwargs): function(**dict).

Float Formatting:

- print("%.2f" % floatNumber)

You might also like