Types Flashcards

1
Q

What is a sequence type?

A

A construct that contains a collection of objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is len()?

A

A function that returns the length of a sequence type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you return an object from a specified index?

A

Write the sequence name with brackets containing the desired index value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What value is the first index in a sequence?

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Can strings be changed?

A

No.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How is concatenation performed?

A

Adding two or more strings together with the + operator. Can be done with literals or variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the Format-string specification types?

A

s - String: Default.
d - Decimal (integer)
,d - Decimal with commas (integer)
x - hexadecimal
e - exponent notation.
f - fixed point notation
.[x]f fixed point to x spaces.
,.[x]f fixed point with commas.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a container?

A

A construct used to group related values together and contain references to other objects instead of data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a list?

A

A mutable container created by surrounding a group of variables or literals with brackets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is an element?

A

A single list item.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is append()?

A

A function that adds an item to the end of a list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is pop(x)?

A

A function that removes the item at index x in a list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is remove(x)?

A

A function that removes the first item of x value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is min(list)?

A

A function that returns the smallest value in a list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is sum(list)?

A

A function that returns the sum of all items in a list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is List.index(x)?

A

A function that returns the location of an item in a sequence.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is list.count(x)?

A

A function that returns the amount of instances of x in a list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a tuple?

A

It is similar to a list but cannot be changed.

19
Q

What is a named tuple?

A

It allows the user to create a simple data type. It is not built-in.

20
Q

What is a set?

A

An unordered collection of items. Does not contain multiples of the same item.

21
Q

Can the index be used in a set?

A

No.

22
Q

How is a set created?

A

By placing a list either between curly braces({[]}), or in the set function (set()).

23
Q

How is an empty set created.

A

It must be done using set().

24
Q

Does list share it’s functions with set?

A

No. It does have remove and pop, however it has add() instead of append().

25
Q

What is add(x)?

A

A function that adds the value x into a set.

26
Q

What is Set1.update(set2)?

A

A function that takes the items in one set and adds them to another.

27
Q

What is clear()?

A

A function that clears all items from a set.

28
Q

What is set.intersection(x, y, z)?

A

A function that returns a set containing the items common between multiple sets.

29
Q

What is set.union(x, y, z)?

A

A function that returns a set with all unique items from each set.

30
Q

What is set.difference(x, y, z)?

A

A function that returns a set with only the elements that are not found in any of the parenthetical sets.

31
Q

What is set1.symmetric_difference(set2)?

A

A function that returns a set with only items that appear in exactly one of set1 or set2.

32
Q

What is a dictionary?

A

A collection of keys and values.

33
Q

What is a key in a dictionary?

A

An item of any immutable type that is associated with a value.

34
Q

How is a dictionary created?

A

By using curly braces surrounding {key : value} pairs.

35
Q

How are items in dictionaries accessed?

A

They must be accessed by using the key. Indexing is not an option.

36
Q

How are items added to a dictionary?

A

dictionary_name[key] = value

37
Q

Are dictionaries immutable?

A

No. The values can be changed the same way items are added, except using keys already present in the dictionary.

38
Q

How are items removed from dictionaries?

A

By using the delete keyword del.
del dictionary_name[key].

39
Q

What is an implicit conversion?

A

Any conversion between types that the interpreter makes automatically.

40
Q

What is the dict.keys() function?

A

A function that returns every key in a dictionary.

41
Q

What is dict.values()?

A

A function that returns every value in dict.

42
Q

What is dict.items()?

A

A function that returns every key value pairs in dict.

43
Q

What is the meaning of empty curly brackets in a print function?

A

It serves as a placeholder for any variables. Print(‘{} is not {}’, x, y)
Output: x is not y