python data structures code example

Example 1: data structures and algorithms in python

great course, highly recommended !

"https://www.udemy.com/course/algorithms-and-data-structures-in-python/"

Example 2: Python dictionary append

# to add key-value pairs to a dictionary:

d1 = {
	"1" : 1,
	"2" : 2,
  	"3" : 3
} # Define the dictionary

d1["4"] = 4 # Add key-value pair "4" is key and 4 is value

print(d1) # will return updated dictionary

Example 3: python data structures

#string
string = 'Hi my name is Dr.Hippo'
#integer(whole number)
integer = 12345
#floating point number
fl = 123.456
#list
li = [1,2,3,,'string',None]
#boolean
t = True
f = False
#none(equivalent to null or undefined in other languages)
n = None
#dictionary
dictionary = {'key':'value'}

Example 4: python data structures

list = [same as array with different features] 
array = [23, 'arrayItem', True, ['Hi', 34, False] ]
dictionary = {'key' : 'value'}
object = class testObj:
tuple = ( "a", "b", "c", "d" ); #same as list but non-changable