Python cheat sheet - data structures¶¶
Only for Python less than 3.0. In python = 3.0 use int data type.: 345L: Long (Python less than 3 only). Python cheat sheet. GitHub Gist: instantly share code, notes, and snippets.
A set of reference materials to help you in those occassional bouts of forgetfulness.
Welcome to Python Cheatsheet!¶ Welcome to pysheeet. This project aims at collecting useful Python snippets in order to enhance pythoneers’ coding experiences. Please feel free to contribute if you have any awesome ideas for improvements to code snippets, explanations, etc. Any snippets are welcome.
Table of contents
- Data structures
- Lists
- Dictionaries
- Tuples
- Sets
- Loops
- Comprehensions
Play area¶¶
Get a feel for Python in Jupyter notebooks. Type commands, press Shift + Enter to run the cells and get the outputs below each cell
Python tutorials and references¶¶
Following are some resources to learn Python
- Article with reviews about various tutorials http://noeticforce.com/best-free-tutorials-to-learn-python-pdfs-ebooks-online-interactive
- user voted list of tutorials on quora: https://www.quora.com/What-is-the-best-online-resource-to-learn-Python
- Google’s Python class https://developers.google.com/edu/python/
- Python reference documentation https://docs.python.org/3/
- A list of Python libraries for various applications: https://github.com/vinta/awesome-python
mutability of lists¶¶
list elements are mutable and can be changed
dict exploration¶¶
what happens when you inquire a key thats not present
Python Cheat Sheet Pdf
set from dictionary¶¶
Github Cheat Sheet
Works on dicts too. But will return a set of keys only, not values.
Python Cheat Sheet Download
Note. When you create a dict with duplicate keys, Python just keeps the last occurrence of the kvp. It thinks the kvp needs to be updated to the latest value
Comprehensions¶¶
Comprehensions are an effective way to loop through sequences
List comprehension¶¶
Python Cheat Sheet Github
Dictionary comprehension¶¶
Same as list comprehension, but instead of lists, it returns a dictionary. You use {} instead of []
reverse keys and values? - works only when values are immutable types. hence filter them out