Python Elementary Indexing Flashcards

 

card 1 of 11

 

(2,3)[0]

 

index by counting items, starting with zero

2

card 2 of 11

 

(2,3)[1]

 

index by counting items, starting with zero

3

card 3 of 11

 

(2,3)[2]

 

index by counting items, starting with zero

IndexError: tuple index out of range

card 4 of 11

 

(5,3,1,0,3)[2+2]

 

expressions for index are evaluated first

3

card 5 of 11

 

"what letter do you want"[15]

 

string indexing is like tuple indexing, with characters as items

'y'

card 6 of 11

 

"magic"[-1]

 

negative index values count backward from end

'c'

card 7 of 11

 

(1,2,3,4,5)[-2]

 

negative index values count backward from end

4

card 8 of 11

 

"once each day"[12-20]

 

negative index values count backward from end

'e'

card 9 of 11

 

"iowa"[-1]+"city"[1]

 

indexing has priority over other operators

'ai'

card 10 of 11

 

(1,2,3,"iowa",4)[3][2]

 

indexing evaluates left-to-right

'w'

card 11 of 11

 

(1,2,3,"iowa",4)[2][3]

 

indexing evaluates left-to-right

TypeError: indexing on an integer not permitted

 

End of Problem Set

(use browser reload to restart this problem set)