CISC 121 Lecture Notes - Lecture 3: Associative Array, Bracket

95 views3 pages
Verified Note

Document Summary

To determine the number of elements in a list, use same len() function used with strings len([ a", 7, 8. 2, fred"]) == 4 # is true. Regarding the len() function, it returns a count of the items in a list, but indexes don"t go that high (as they"re 0-based). my_list = [2, 44, 0, hello", 7] When declaring, initializing or adding elements to a list, you can use literals/variables. As each list element is a variable in itself, its value is changeable (i. e. with an assignment). To distinguish methods from functions in these notes, we will make an effort to write methods with a preceding period. Method: specialized function specific to a particular data type (unlike len() function, which can be used on strings and lists). It is evident when a method is being used instead of a function, as it"s invoked in a specific way. You can also use the internet to help determine which you are dealing with.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents