Python Advanced Summary
Summary of Python Advanced Fundamentals
This page covers all main points throughout the Python advanced fundamentals.
String Formatting (more)
- f-strings and format method are more beneficial
- % operator, concatenation, and comma methods have limitations
Python Advanced (more)
- Python allows saving code into own modules
- importing occurs through the normal keyword “import”
- built-in “dir()” function outputs features of an object
Python Advanced Data Types (more)
- third argument (steps) in slicing sets the slicing step
- negative indexing reverses the order of slicing (back to front)
- “sort()” executes onto original data, “sorted()” executes onto copied data
- “sort()” is exclusive to lists, “sorted()” applies to various data types
- sorting reverse argument reverses the order
- referencing only references a variable to another (no new object)
- shallow copying creates new object, but references original content to copy
- deep copying creates new object and copies all original content to copy
Python Advanced Conditions (more)
- logical operators(and, or, and not)
- membership operators (in and not in)
- identity operators (is and is not)
Python Advanced Loops (more)
- “else” statement executes code once the loop finishes
- if loop is interrupted, “else” statement does not output
- nested loops execute one loop inside another
- outer loop iterate once, inner loop iterate all possibilities
Python Random (more)
- “random()” outputs a random float number between 0 and 1
- “randint()” outputs a random integer number between a given range
- “choice()” outputs a random item from a data type
- “sample()” outputs a random item(s) from a data type
- “choices()” outputs a random selection from a data type
- “shuffle()” outputs a randomly shuffled sequence from a data type
- “seed()” initialises a random generator
Python Advanced Functions (more)
- arbitrary arguments (*args) tackles identity issues
- keyword arbitrary arguments (**kwargs) tackles parament/argument identity issues
- recursion is essentially a function calling itself
Python Advanced Classes (more)
- inheritance passes properties and methods from one class to another
- the class passing the features is the parent class
- the class receiving the features is the child class
- child class can have features on its own
- child class can overwrite parent class features
- “super()” function passes all features from a parent class to a child class
- “super()” function advances with multiple inheritance
Python Advanced Files (more)
- “os” module allows deletion of files
- “pathlib” module allows deletion of files
- “os” module allows deletion of empty directories
- “shutil” module allows deletion of non-empty directories
Python Advanced Errors (more)
- “with” statement uses exception handling
- “with” statement provides higher code efficiency
- “with” statement does not need file closing
- “raise” allows raising exceptions