Python Data Types, Collections, and NumPy Arrays: Key Concepts and Methods

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/80

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:34 PM on 3/24/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

81 Terms

1
New cards

What are collections?

Prepackaged data structures of related data items

2
New cards

What are the four built-in data types in Python used to store collections of data?

List, tuple, set, dictionary

3
New cards

How is a list created?

By placing elements inside square brackets ([]), separated by commas.

4
New cards

What is the difference between lists and tuples in Python?

Lists are modifiable (mutable), while tuples are not (immutable).

5
New cards

What do list typically store?

Homogeneous data

6
New cards

Can list store heteogenous data?

Yes

7
New cards

What can list do as necassary?

Dynamically resize

8
New cards

What function can be used to determine the length of a list?

Len

9
New cards

What does the sum function do?

adds all the numbers in a range

10
New cards

Are python's string mutable or immutable?

Mutable

11
New cards

What method can be used to concatenate two lists in Python?

Using the + operator or += operator.

12
New cards

Tuple items are:

ordered, unchangeable

13
New cards

Do tuple items allow duplicate values?

Yes

14
New cards

How is a tuple created?

By placing a sequence of comma-separated items inside round brackets ()

15
New cards

How can you create an empty tuple in Python?

By using empty parentheses ()

16
New cards

How do we pack a tuple?

By separating its values with commas

17
New cards

What is required to create a one-element tuple?

A Comma

e.g: ('red,)

18
New cards

What does the tuple() function do?

convert other iterable objects (like lists, strings, sets, or dictionaries) into an immutable tuple, or to create an empty tuple.

19
New cards

What comparison operator can be used with tuples, even though they are immutable?

+=

20
New cards

What does += do when used with tuples?

Creates new objects

21
New cards

Can tuples contain mutable objects?

Yes

22
New cards

How can we unpack a sequence's elements?

By assigning the sequence to a comma-separated list of variables

23
New cards

What is the purpose of the enumerate() function?

To access an element's index and value in an iterable.

24
New cards

What does enumerate() receive?

An iterable which it uses to create an iterator that, for each element, returns a tuple containing the element's index and value

25
New cards

Why are sequences sliced?

To create new sequences of the same type containing subsets of the original elements

26
New cards

Slice operations that do not modify a sequence work identically for?

lists, tuples, and strings

27
New cards

How do we modify lists via slices?

By using the syntax: example_list[start:stop:step] = new_iterable

28
New cards

What does the del function do?

Deletes target from the list

29
New cards

How do we delete an element from a list?

using the syntax: del variable_name[gini #]

30
New cards

How do we delete a slice from a list?

using the syntax: del variable_name [ : ]

31
New cards

How do we delete a variable from a list?

using the syntax: del variable_name

32
New cards

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

It modifies a list in place to sort its elements.

33
New cards

What does the sorted() function do?

It returns a new list containing the sorted elements of its argument sequence.

34
New cards

What is the significance of the term 'immutable' in relation to tuples?

It means that once a tuple is created, its elements cannot be changed.

35
New cards

How can you access elements of a list?

By using their index, e.g., G[0], G[1], etc.

36
New cards

How do we insert an object at a specific list index?

.insert(gini position, variable to be inserted)

37
New cards

How can you add an element to the end of a list?

.append()

38
New cards

How can you add all the elements of a sequence to the end of a list?

.extend()

39
New cards

What function removes the first occurrence of an element in a list?

.remove

40
New cards

What is the method to count occurrences of an item in a list?

.count()

41
New cards

How do we empty a list?

Using [ ]

42
New cards

What is list comprehension in Python?

A concise way to create lists by iterating over an iterable and applying an expression.

43
New cards

What does the for clause in a list comprehension do?

It iterates over a sequence and evaluates an expression for each item.

44
New cards

For each item, what does list comprehension evaluate?

The expression to the left of the 'for' clause and places the expression's value in the new list

45
New cards

How do you replace an item in a list?

By assigning a new value to the specific index of the list.

46
New cards

What does the term 'homogeneous data' refer to in lists?

Data that consists of elements of the same type.

47
New cards

What does it mean for lists to be dynamic in size?

Lists can grow or shrink in size as items are added or removed.

48
New cards

What is the difference between mutable and immutable objects?

Mutable objects can be changed after creation, while immutable objects cannot.

49
New cards

What is mapping in the context of list comprehension?

A functional-style programming operation that produces a result with the same number of elements as the original data.

50
New cards

What is the purpose of the zip() function?

To iterate over multiple iterables and produce tuples of corresponding elements.

51
New cards

What does zip() receive?

Any number of iterables and returns and iterator that produces tuples containing the elements are the same index in each

52
New cards

What is the NumPy library used for?

It is the preferred Python array implementation, critical for big-data processing and AI applications.

53
New cards

What is an ndarray in NumPy?

A high-performance, n-dimensional array type that is up to 100 times faster than Python lists.

54
New cards

How can you create a NumPy array from existing data?

By using the array() function with an iterable as an argument.

55
New cards

What is the argument for the array() function?

an array or other iterable

56
New cards

What does the array() function return?

A new array containing the argument's elements

57
New cards

What do array Attributes do?

Enable you to discover information about its structure and contents

58
New cards

What function allows you to discover element type in arrays?

.dtype

59
New cards

What function allows you to discover element dimension in arrays?

.ndim

60
New cards

What function allows you to discover element shape in arrays?

.shape

61
New cards

What function allows you to discover element size in arrays?

.size/.itemsize

62
New cards

What does the .itemsize function do?

Shows the number of bytes required to store each element

63
New cards

What is the purpose of the zeros(), ones(), and full() functions in NumPy?

To fill arrays with specific values.

64
New cards

How are the zeros(), ones(), and full() fuctions converted in array?

np.zero, np.ones, np.full

65
New cards

What do array operators do?

Perform arithmetic operations and augmented assignments between arrays of the same shape

66
New cards

What does the itemsize attribute of a NumPy array indicate?

The number of bytes required to store each element in the array.

67
New cards

How do you select an element in a two-dimensional NumPy array?

By specifying the row and column indices in square brackets.

68
New cards

What is a deep copy in Python?

A copy of an object that is completely independent of the original, created using the .copy() method.

69
New cards

What are the characteristics of a set in Python?

Sets are unordered, unchangeable, and do not allow duplicate values.

70
New cards

What is a dictionary in Python?

A collection that is ordered, changeable, and does not allow duplicates.

71
New cards

How can you access elements in a dictionary?

Using methods like item(), keys(), and values().

72
New cards

What methods can be used to add or remove data in a dictionary?

You can use methods like del and pop() to delete data, and simply assign values to add data.

73
New cards

What is the output of the code print(type({'Vladimir', 34, 55000}))?

C: set

74
New cards

What is the command to store a copy of a list in Python?

my_list_original = my_list.copy()

75
New cards

What is the significance of the NumPy library in scientific computing?

It provides a core library for efficient numerical operations and is foundational for many data science libraries.

76
New cards

What does the term 'slicing' refer to in the context of arrays?

Selecting a subset of elements from an array based on specified indices.

77
New cards

What is the output of the command my_list = [12, 23, 43, 21]; my_list_original = my_list?

my_list_original refers to the same list as my_list, not a copy.

78
New cards

What is the purpose of the comparison operations in NumPy?

To perform element-wise comparisons, producing arrays of Boolean values.

79
New cards

What is the role of universal functions in NumPy?

To perform mathematical, trigonometric, and comparison operations on arrays.

80
New cards

What is the difference between a set and a dictionary in Python?

A set is unordered and unindexed with no duplicates, while a dictionary is ordered, changeable, and does not allow duplicates.

81
New cards

What does the function .pop() do?

remove and return a specific element

Explore top notes

note
Chapter 9: Chemical Equilibrium
Updated 1095d ago
0.0(0)
note
Wedding Wind
Updated 1257d ago
0.0(0)
note
College Prep Chemistry, Elements
Updated 1281d ago
0.0(0)
note
Grade 10 Biology: Lesson 9
Updated 1181d ago
0.0(0)
note
Chapter 9: Chemical Equilibrium
Updated 1095d ago
0.0(0)
note
Wedding Wind
Updated 1257d ago
0.0(0)
note
College Prep Chemistry, Elements
Updated 1281d ago
0.0(0)
note
Grade 10 Biology: Lesson 9
Updated 1181d ago
0.0(0)

Explore top flashcards

flashcards
Odyssey Test review
85
Updated 535d ago
0.0(0)
flashcards
duits kapitel 2 woordenschat
101
Updated 878d ago
0.0(0)
flashcards
US State Capitals
50
Updated 937d ago
0.0(0)
flashcards
APUSH 23-25 Simple IDs
90
Updated 60d ago
0.0(0)
flashcards
French Indefinite Articles
34
Updated 705d ago
0.0(0)
flashcards
AP Psych Unit 3
79
Updated 861d ago
0.0(0)
flashcards
Waves key words and definitions
21
Updated 476d ago
0.0(0)
flashcards
Map of East Asia- Physical map
34
Updated 428d ago
0.0(0)
flashcards
Odyssey Test review
85
Updated 535d ago
0.0(0)
flashcards
duits kapitel 2 woordenschat
101
Updated 878d ago
0.0(0)
flashcards
US State Capitals
50
Updated 937d ago
0.0(0)
flashcards
APUSH 23-25 Simple IDs
90
Updated 60d ago
0.0(0)
flashcards
French Indefinite Articles
34
Updated 705d ago
0.0(0)
flashcards
AP Psych Unit 3
79
Updated 861d ago
0.0(0)
flashcards
Waves key words and definitions
21
Updated 476d ago
0.0(0)
flashcards
Map of East Asia- Physical map
34
Updated 428d ago
0.0(0)