Code Efficiency
- Remove unnecessary code
- Investigate loops and remove unnecessary code from within
- Break out of a loop if task is complete
- Improve the speed of code
- Choose the correct data structure
- Use built-in functions when relevant (they have been highly optimised)
- Explore different algorithm for the same task
Time
Module
import time as t
t1 = t.time()
# Testing code here
t2 = t.time()
dt = t2 - t1
print(dt)
Programming Paradigms

- Each programming language can be classified based on its features described by a Programming Paradigm
- Each language can be classified into multiple paradigms
Machine Code & Assembly Language
Machine Code
The lowest-level paradigm that directly represents the instructions as a sequence of binary numbers
Assembly Language
Machine instructions by mnemonics and memory addresses by symbolic labels
Imperative Programming
- Imperative Programming is a programming paradigm that uses statements that change a program’s state
- Statements are executed in sequence
- Example features:
- Direct assignment, common data structure, global variables
- Programming language that use imperative programming: