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

Python Theory Notes

This document provides a summary of key Python concepts including dictionaries, tuples, sets, strings, file handling, and popular libraries. It outlines the characteristics and basic operations for each data type and library. Essential methods and functions for manipulating these data structures are also highlighted.

Uploaded by

dovahkiinsak
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)
8 views2 pages

Python Theory Notes

This document provides a summary of key Python concepts including dictionaries, tuples, sets, strings, file handling, and popular libraries. It outlines the characteristics and basic operations for each data type and library. Essential methods and functions for manipulating these data structures are also highlighted.

Uploaded by

dovahkiinsak
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 Notes Summary

1. Dictionary Data Type

A dictionary is an unordered collection of key-value pairs. Keys must be unique and immutable.

Creating: my_dict = {"name": "Alice", "age": 25}


Accessing: my_dict["name"]
Modifying: my_dict["age"] = 26
Functions: len(), type(), str()
Methods: keys(), values(), items(), get(), pop(), clear()

2. Tuples and Sets

Tuples are ordered and immutable. Sets are unordered, mutable, and do not allow duplicates.

Tuples:
Creating: t = (1, 2, 3)
Indexing: t[0], Slicing: t[1:3]
Functions: len(), max(), min(), sum()

Sets:
Creating: s = {1, 2, 3}
Methods: add(), remove(), discard(), update(), union(), intersection(), difference()
Traversal: for i in s: print(i)

3. Strings

Strings are sequences of characters.

Creating: s = "Hello"
Accessing: s[0], Slicing: s[1:4]
Operations: +, *, in
Methods: lower(), upper(), strip(), replace(), split(), find()
Formatting: f"My name is {name}"

4. Files

Files can be text or binary.

Creating/Reading:
Write: open("[Link]", "w")
Read: open("[Link]", "r")
Modes: 'r', 'w', 'a', 'r+'

5. Python Libraries

NumPy: Array operations and numerical computing.


Pandas: Data manipulation with DataFrames.
Matplotlib: Data visualization (plots, graphs).
Python Notes Summary

Scikit-learn: Machine learning (model training, prediction).

You might also like