Python: Data Types

Integer
result = 5
Float
pi = 3.1415926
Boolean
tamara_boolean = True
jack_boolean = False
String
name = "Tamara"
None
null_value = None
List
fruits_list = ["apple", "orange", "banana"]
Dictionary

-store Key/Value pairs

employee = {

"name": "John"

"surname": "Smith"

"age": 35

"details": None

}
List of Dictionaries

employees = [

{ "name": "John" "surname": "Smith" "age": 35 },

{ "name": "Mary" "surname": "South" "age": 23 },

{ "name": "Robert" "surname": "Rupert" "age": 41 }

]

Complex
Long

– Python 2 only

Bytes
Bytearray
Tuple

– immutable list

Set
Frozenset

 

 

 

 

Continue Reading

Quick Sort Pseudocode

QUICKSORT(ARRAY, left, right)
   IF left < right
      p = PARTITION(ARRAY, left, right)
      QUICKSORT(ARRAY, left, p - 1)
      QUICKSORT(ARRAY, p + 1, right)


PARTITION(ARRAY, left, right)
   pivot = ARRAY[right];
   boundary = left - 1
   FOR j = left to right - 1
      IF(ARRAY[j] <= pivot)
         boundary++
         EXCHANGE(ARRAY[boundary] with ARRAY[j])
   EXCHANGE(ARRAY[boundary + 1] with ARRAY[right])
   return boundary + 1
Continue Reading