Natarajan Santhosh

May 25, 2021

1 min read

Python

Data structures

How it works under the hood

  • List
  • Set
  • Tuple
  • Dictionary

These are examples of sequence and they have membership test e.g. in or not in. Apple in fruits.

For list and tuple these are O(n)

For set and dict it’s O(1) since they use hashing

There are three control flow statements in Python — if, for and while.

The continue statement is used to tell Python to skip the rest of the statements in the current loop block and to continue to the next iteration of the loop.

The break statement is used to break out of a loop statement i.e. stop the execution of a looping statement, even if the loop condition has not become False or the sequence of items has not been completely iterated over.

An important note is that if you break out of a for or while loop, any corresponding loop else block is not executed.