Python Tuples and Lists

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

tuple with a single item

If a tuple has just one item in it, it has to be followed by a comma or python won't recognize it as a tuple. example: number =(1,)

Reverse() method

Reverses the order of the items in the list.

Lists

a heterogenous, MUTABLE, data type that stores an ordered sequence of things, lists are indicated by square brackets numbers=[1,2,3,4,5]

Tuple

a heterogenous, immutable data type that stores an ordered sequence of thing. The parts for a tuple are name of tuple, followed by an = and parenthesis with your info separated by commas. example: numbers=(1,2,3,4)

heterogenous

a single tuple can store multiple different types of things

append method

adds a single item to the end of a list example: my_list.append(2)

extend method

allows us to add multiple items to a list at once my_list.extend(["a", "b", "c"])

List function

allows us to convert a string into a list variable = list(name of string)

enumerate () function

allows us to number the positions of the items in our list

sort method

arranges items in "Python" order

split method

copies the strings, breaks it into smaller strings based on where it finds white space, puts those smaller strings into a list, and then returns the list

join() method

of a list can be used to combine the items in the list into a string that's separated by delimiters variable = "".join()

python methods

similar to functions, except they get "called" on something format: variable = name(this is the variable you're calling it on).method name

Data Structures

techniques for organizing and storing data in computer memory

immutable

unchangeable - can't be changed

remove method

will remove the "first" instance of an item in a list


Ensembles d'études connexes

Federal Tax considerations for Life and Annuities

View Set

Rational Equations Assignment Answers

View Set

Chapter 27: Antitrust Law (quiz 97.5/100)

View Set

Ap euro elizabeth R the lions cub

View Set

CH 19: Wrist and Hand Conditions

View Set

Chapter 16: The Nursing Role in Providing Comfort During Labor and Birth

View Set