My QA Projects

QA Projects I was involded.

View on GitHub

Nested containers

what are nested containers?

Nested list Examples

[[55,,60,93,28], [77,45,23,95],[23,88,62]]
[(1,1,1), (10,20,10),(-10,-10,-10),(20,0,0)]
[{'name':'James", 'hire_date':'2017/10/5'}, 
{'name':'Jana", 'hire_date':'2021/10/5'}, 
{'name':'Jae", 'hire_date':'2016/10/5'}, 
]
{
    'dairy':['milk', 'cheese','yoghurt'],
    'fruit':['apple', 'banana','grapes','durian'],
    'vegetable':['carrot', 'kale','lettuce','eggplant']
}

the keys are the categories, and the values are lists of items

{
    'CA':{'name': 'California', 'capital': 'Sacramento','area':'163696'},
    'OR':{'name': 'Oregon', 'capital': 'Salem','grapes','area':'93381'},
    'WA':{'name': 'Washington', 'capital': 'Olympia','area':'71362'}
}

Nested Container indexing

coord = [(-2,1),(2,-1),(3,4)]

  0 1 2
(-2,1) (2,-1) (3,4)  
  expression value
at coord[0] we get the tuple (-2,1)  
  expression value
at coord[0] we get the tuple (-2,1)  
  expression value
at coord[0][0] -2  
at coord[0][1] 1  
at coord[1][0] 2  
at coord[1][1] -1  

https://ucbx.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=19fa5338-360a-4065-8821-aeef00c648ad


Nested Container Iteration

scorelist = [[38,62,93], [28], [64,76]]
#a list of lists
for outer_item in scorelist:
    #the outerloop
    for inner_item in outer_item:
        #inner loop
        print(inner_item, end='')
    print()

# Output

first iteration of the outer loop

  name value
outer_item [38,62,93]  
inner_item 38  

|| Strings || Variables || Lists || Tuples || Dictionary || || Control || Function|| Files || Exceptions || || OOP || Algorithm ||Data Structure ||back