# on 29-Aug-2019 (Thu)

#### Flashcard 4348457127180

Tags
#bones #bony #has-images #knee #landmarks #leg #patella

status measured difficulty not learned 37% [default] 0

#### Flashcard 4353801194764

Question
How to merge two dictionaries
>>> x = { 'a' : 1, 'b' : 2} >>> y = { 'b' : 3, 'c' : 4} >>> z = { ** x, ** y} >>> z {'c': 4, 'a': 1, 'b': 3} # In Python 2.x you could # use this: >>> z = dict (x, ** y) >>> z {'a': 1, 'c': 4, 'b': 3} # In these examples, Python merges dictionary keys # in the order listed in the expression, overwriting # duplicates from left to right.

status measured difficulty not learned 37% [default] 0
Unknown title
# How to merge two dictionaries # in Python 3.5+ >>> x = {'a': 1, 'b': 2} >>> y = {'b': 3, 'c': 4} >>> z = {**x, **y} >>> z {'c': 4, 'a': 1, 'b': 3} # In Python 2.x you could # use

#### Flashcard 4353805913356

Question
# Different ways to test multiple # flags at once in Python

x, y, z = 0, 1, 0

if x == 1 or y == 1 or z == 1: print ( 'passed' )

if 1 in (x, y, z): print ( 'passed' )

# These only test for truthiness:

if x or y or z: print ( 'passed' )

if any ((x, y, z)): print ( 'passed' )

status measured difficulty not learned 37% [default] 0
Unknown title
# Different ways to test multiple # flags at once in Python x, y, z = 0, 1, 0 if x == 1 or y == 1 or z == 1: print('passed') if 1 in (x, y, z): print('passed') # These only test for truthiness: if x or y or z: print('passed') if any((x, y, z)):

#### Flashcard 4353810369804

Question
# The get() method on dicts # and its "default" argument

name_for_userid = { 382: "Alice" , 590: "Bob" , 951: "Dilbert" , }

def greeting(userid): return "Hi %s!" % name_for_userid . get(userid, "there" )

>>> greeting(382) "Hi Alice!"

>>> greeting(333333) "Hi there!"

status measured difficulty not learned 37% [default] 0
Unknown title
# The get() method on dicts # and its "default" argument name_for_userid = { 382: "Alice", 590: "Bob", 951: "Dilbert", } def greeting(userid): return "Hi %s!" % name_for_userid.get(userid, "there") >>> greeting(382) "Hi Alice!" >&

#### Flashcard 4353815874828

Question
# Using namedtuple is way shorter than # defining a class manually:

>>> from collections import namedtuple

>>> Car = namedtuple( 'Car' , 'color mileage' ) # Our new "Car" class works as expected:

>>> my_car = Car( 'red' , 3812.4)

>>> my_car . color

'red'

>>> my_car . mileage

3812.4

>>> my_car Car(color='red' , mileage=3812.4)

# Like tuples, namedtuples are immutable:

>>> my_car . color = 'blue' AttributeError: "can't set attribute"

status measured difficulty not learned 37% [default] 0
Unknown title
# Why Python is Great: Namedtuples # Using namedtuple is way shorter than # defining a class manually: >>> from collections import namedtuple >>> Car = namedtuple('Car', 'color mileage') # Our new "Car" class works as expected: >>> my_car = Car('red', 3812.4) &

#### Flashcard 4353852312844

Tags
#christina
Question
Tia
786738

status measured difficulty not learned 37% [default] 0

#### Flashcard 4353855196428

Tags
#bones #bony #has-images #knee #landmarks

status measured difficulty not learned 37% [default] 0

#### Flashcard 4353860701452

Tags
#bones #bony #has-images #knee #landmarks

status measured difficulty not learned 37% [default] 0

#### Flashcard 4353867255052

Tags
#bones #bony #has-images #knee #landmarks

status measured difficulty not learned 37% [default] 0

#### Flashcard 4353872760076

Tags
#bones #bony #has-images #knee #landmarks

status measured difficulty not learned 37% [default] 0

#### Flashcard 4353879051532

Tags
#bones #bony #femur #has-images #landmarks #master

status measured difficulty not learned 37% [default] 0

#### Flashcard 4353884556556

Tags
#bones #bony #femur #has-images #landmarks

status measured difficulty not learned 37% [default] 0

#### Flashcard 4353890061580

Tags
#bones #bony #femur #has-images #landmarks

status measured difficulty not learned 37% [default] 0