• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/13

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

13 Cards in this Set

  • Front
  • Back

inventory = {'apple': 430, 'banana':312}


print(list(inventory.values()))

[430,312]

inventory = {'apple': 430, 'banana':312} print(list(inventory.items()))

[('banana', 312), ('apple', 430)]

inventory = {'apple': 430, 'banana':312}




for (k,v) in inventory.items():


print (k, v)



apple 430


banana 312

inventory = {'apple': 430, 'banana':312}




print(inventory.get('apple'))


print(inventory.get('soda'))


print(inventory.get('soda', 0))

430


None


0

Difference between using inventory.get('apple') and print(inventory['apple']) ?

No difference except if .get doesn't find the dict it won't cause a error

opposite = {'up':'down', 'right':'wrong'}


alias = opposite


alias['right'] = 'left'


print(opposite['right'])

left




It mutates it

opposite = {'up':'down', 'right':'wrong'}


alias = opposite.copy()


alias['right'] = 'left'


print(opposite['right'])


print(alias['right'])

'wrong'


'left'




it copies it

matrix = {(0,3):1}


print(matrix.get((0,3)))

1

c = [('a',1)]


c = dict(c)


print(c)

{'a':1}

a = set([1,5])


print(a)


a.add(5)


print(a)


a.add(6)


print(a)

{1,5}


{1,5}


{1,5,6}

a = {}


a['uno'] =


'uno'print(a)

{'uno': 'uno'}

inventory = {'apple':20, "pears":35}


del inventory['pears']


print(inventory)


print(list(inventory.keys())

{'apple': 20}


['apple']

inventory = {'apple':20, "pears":35}


for k in inventory:


print(k, + " -> " + str(inventory[k]))

apple -> 20


pears -> 35