Python Exam 2 Conceptual Review Session

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/32

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

33 Terms

1
New cards
What method can be called on a list to add an item?
.append()
2
New cards
Which datatype is accessed with the .items() method?
dict
3
New cards
What characteristic means that elements can be changed in a datatype?
Mutable
4
New cards
Are tuples indexed?
YES
5
New cards
Which datatype is known to be ordered?
List
6
New cards
What method counts the occurrences of an item in a tuple?
.count(item)
7
New cards
What will myList[0] return if myList = [1,2,3]?
1
8
New cards
Are dictionary keys mutable?
NO
9
New cards
How do you access a value in a dictionary?
By using the key, e.g., myDict[key]
10
New cards
What method can be called on a string to remove whitespace?
.strip(chars)
11
New cards
What does the .split() method do in Python?
Splits a string into a list based on a separator.
12
New cards
What will be the return value of sorted() when a list is passed?
A sorted list without modifying the original.
13
New cards
How do you check if an item is in a list?
Using the 'in' keyword.
14
New cards
What is the primary way to add an item to a list?
.append()
15
New cards
What is the output of the statement myList.reverse()?
None; it modifies the original list.
16
New cards
What occurs if you attempt to call index on a value not found in a list?
An error is thrown.
17
New cards
Are dictionary values mutable?
YES
18
New cards
What does tuple unpacking allow you to do?
Assign variables to values directly from a tuple.
19
New cards
What will 'del myList[0]' do?
Delete the first element of myList.
20
New cards
What does the random module's .random() function return?
A random float between [0,1).
21
New cards
Which method returns the index of an item in a tuple?
.index(item)
22
New cards
What happens in tuple packing?
Values are packed into the tuple.
23
New cards
How are dictionaries used to count letter occurrences?
By incrementing the count for each letter in a looping structure.
24
New cards
What is the significance of using the import statement before a module?
It allows access to the functions and variables defined in that module.
25
New cards
What happens when you try to add duplicate keys to a dictionary?
Only the last assignment to the key will be kept.
26
New cards
What is unique about the elements in a dictionary?
Keys must be unique.
27
New cards
What is a key characteristic of lists in Python?
They are mutable.
28
New cards
What will myTuple[0] return if myTuple = (1,2,3)?
1
29
New cards
What does the range function return?
A sequence of numbers in a specified range.
30
New cards
To mutate items in a tuple, what must be done?
You must create a new tuple.
31
New cards
What is the purpose of the .replace() method in strings?
To return a new string with specified substrings replaced.
32
New cards
What are the characteristics of a dictionary?
Keys are unique and values can be mutable.
33
New cards
How to check if two items are identical?
Use '==' operator.