Python Intermediate Summary
Summary of Python Intermediate Fundamentals
This page covers all main points throughout the Python intermediate fundamentals.
Python Speed Performance (more)
- code performance is vital in larger projects
- background processes impact code execution
- processing time is the CPU performance measurement
- four built-in packages: time, datetime, timeit, and cProfile
Python Intermediate (more)
- local variables work only in the local scope
- global variables work everywhere
- Python can assign multiple variables
- naming variables is vital (PEP8)
- possible to import multiple modules (not recommended)
- possible to import multiple functions
- asterisk (*) can import all (not recommended)
Python Intermediate Data Types (more)
- casting converts one data type to another – e.g. “float(4)”
- slicing cuts data types partially – e.g. a[2:15]
- “split()” separate text and outputs a list
- “strip()” removes empty spaces (beginning or end)
- “lower()” changes letters to all lowercase
- “upper()” changes letters to all uppercase
- “min()” & “max()” outputs lowest and maximum number, respectively
- “pow()” refers to the power of a number
- “abs()” produces the absolute value of a number
- indexing provides access to a specific item in a data type

- “sort()” arranges items in lists
- “len()” outputs the number of items in data types
- “count()” outputs the specific number of items in data types
Adding items
- “in” & “and” check items in a set
- dictionaries use keys for indexing
- “append()” & “insert()” add items in lists
- “add()” adds items in sets
- “update()” or new pair assignment add items in dictionaries
Removing items
- “pop()”, “remove()”, & “del” remove items from lists
- “discard()”, “remove()”, & “pop()” remove items from sets
- “pop()”, “popitem()”, & “del” remove items from dictionaries
Modifying items
- indexing and slicing modify items in lists
- “update()” & new pair assignment modify items in dictionaries
Python Intermediate Conditions (more)
- modulus (%) returns the remainder of two divided numbers
- exponential (*) raises a number to the power of another
- floor division (//) divides a number by another
- a += 1 is the short form for a = a +1
- “pass” statements bypass errors in empty conditional statements
- a nested “if” statement is one statement in another
- short form “if” statement – e.g. if a < 10: print (a, “is less than 10”)
Python Intermediate Loops (more)
- “continue” skips an iteration and continues with the rest
- “pass” statements bypass errors in empty loops
- a nested loop is one loop inside another
Python Intermediate Range (more)
- range is a built-in Python function
- outputs a sequence of numbers
- three arguments: start, end, and step
- only end argument is mandatory
- start = 0 and step = 1 by default
- common usage with loops
Python Intermediate Functions (more)
- keyword arguments avoid order issues
- default parameters set the default value settings
- “pass” statements bypass errors in empty functions
- “return” statements output values
- lambda is a small (single line) function – multiple arguments and only one output expression
Python Intermediate Classes (more)
- objects’ values can change through new value assignment
- “del” removes either object properties or entire objects
- “pass” statements bypass errors in empty classes
- “__str()__” returns the representation of the object in string format
Python Intermediate Files (more)
- both append and write modes create new file if non-existent
- “write()” writes new text into a file
- escape characters bypass special symbols in strings
- “\t” produces empty spaces (tab)
- “\n” produces a new line
- “\” escape symbols
Python Intermediate Errors (more)
- “except” statements execute only in the case of errors in the code
- “else” statements execute only in the case of no errors in the code
- “except” statements always execute, with errors or not