Exam 2 Conceptual Review Session

studied byStudied by 0 people
0.0(0)
Get a hint
Hint

What method can be called on a list to add an item?

1 / 32

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

33 Terms

1

What method can be called on a list to add an item?

.append()

New cards
2

Which datatype is accessed with the .items() method?

dict

New cards
3

What characteristic means that elements can be changed in a datatype?

Mutable

New cards
4

Are tuples indexed?

YES

New cards
5

Which datatype is known to be ordered?

List

New cards
6

What method counts the occurrences of an item in a tuple?

.count(item)

New cards
7

What will myList[0] return if myList = [1,2,3]?

1

New cards
8

Are dictionary keys mutable?

NO

New cards
9

How do you access a value in a dictionary?

By using the key, e.g., myDict[key]

New cards
10

What method can be called on a string to remove whitespace?

.strip(chars)

New cards
11

What does the .split() method do in Python?

Splits a string into a list based on a separator.

New cards
12

What will be the return value of sorted() when a list is passed?

A sorted list without modifying the original.

New cards
13

How do you check if an item is in a list?

Using the 'in' keyword.

New cards
14

What is the primary way to add an item to a list?

.append()

New cards
15

What is the output of the statement myList.reverse()?

None; it modifies the original list.

New cards
16

What occurs if you attempt to call index on a value not found in a list?

An error is thrown.

New cards
17

Are dictionary values mutable?

YES

New cards
18

What does tuple unpacking allow you to do?

Assign variables to values directly from a tuple.

New cards
19

What will 'del myList[0]' do?

Delete the first element of myList.

New cards
20

What does the random module's .random() function return?

A random float between [0,1).

New cards
21

Which method returns the index of an item in a tuple?

.index(item)

New cards
22

What happens in tuple packing?

Values are packed into the tuple.

New cards
23

How are dictionaries used to count letter occurrences?

By incrementing the count for each letter in a looping structure.

New cards
24

What is the significance of using the import statement before a module?

It allows access to the functions and variables defined in that module.

New cards
25

What happens when you try to add duplicate keys to a dictionary?

Only the last assignment to the key will be kept.

New cards
26

What is unique about the elements in a dictionary?

Keys must be unique.

New cards
27

What is a key characteristic of lists in Python?

They are mutable.

New cards
28

What will myTuple[0] return if myTuple = (1,2,3)?

1

New cards
29

What does the range function return?

A sequence of numbers in a specified range.

New cards
30

To mutate items in a tuple, what must be done?

You must create a new tuple.

New cards
31

What is the purpose of the .replace() method in strings?

To return a new string with specified substrings replaced.

New cards
32

What are the characteristics of a dictionary?

Keys are unique and values can be mutable.

New cards
33

How to check if two items are identical?

Use '==' operator.

New cards

Explore top notes

note Note
studied byStudied by 11 people
... ago
5.0(1)
note Note
studied byStudied by 12 people
... ago
5.0(1)
note Note
studied byStudied by 9 people
... ago
5.0(1)
note Note
studied byStudied by 5 people
... ago
5.0(1)
note Note
studied byStudied by 51 people
... ago
5.0(1)
note Note
studied byStudied by 4 people
... ago
5.0(1)
note Note
studied byStudied by 13 people
... ago
5.0(1)
note Note
studied byStudied by 34930 people
... ago
4.6(69)

Explore top flashcards

flashcards Flashcard (102)
studied byStudied by 31 people
... ago
5.0(1)
flashcards Flashcard (20)
studied byStudied by 2 people
... ago
5.0(2)
flashcards Flashcard (22)
studied byStudied by 7 people
... ago
4.3(3)
flashcards Flashcard (21)
studied byStudied by 10 people
... ago
5.0(1)
flashcards Flashcard (32)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (121)
studied byStudied by 37 people
... ago
5.0(1)
flashcards Flashcard (58)
studied byStudied by 4 people
... ago
5.0(1)
flashcards Flashcard (250)
studied byStudied by 4 people
... ago
5.0(2)
robot