Data Types and Structures Flashcards

1
Q

What is an Integer Data Type classified by?

A

An integer is a data type which is a number without a decimal point and is defined by the function int().

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

What is an Float Data Type classified by?

A

A float is a data type which is a number with a decimal point and is defined by the function float().

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

Which function can be used to find out which data type is a certain value?

A

You can use the type() function.

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

What happens when you use the int() function on a float value?

A

The value after the decimal point is taken off and no rounding occurs.

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

What happens when you use the float() function on an integer value?

A

A decimal point and a 0 is appended onto the number.

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

What is a boolean?

A

A boolean is a data type that can have a value of true or false. (Created by George Bool, Boolean Algebra)

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

What does != mean?

A

!= means not equal to. (Comparison Operator)

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

What type of operators are and, not and or?

A

Logical Operators

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

What is a string classified by?

A

It is classified by double or single quotes.

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

How do you tell Python that this quote is in the string not the syntax?

A

By using a backslash. ()

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

What is the symbol to add and multiply strings?

A

+ for addition; * for multiplication

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

How can you reference the first item of a list?

A

print(list_name[0])

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

How can you reference the last item of a list?

A

print(list_name[-1]) (Not print(list name[-0])

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

What code do you use to slice the list from index 5 to 9?

A

print(list_name[5:9])

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

What is a tuple?

A

A data type for immutable ordered sequence of elements.

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

What is a set?

A

A data type for mutable unordered collections of unique elements.

17
Q

What is a list?

A

A data type for mutable ordered list of data

18
Q

Is a string mutable?

A

No, a string is an immutable ordered data type.

19
Q

What is a dictionary in Python?

A

A dictionary is a data type for mutable objects that store mapping s of unique keys to values.

20
Q

What is the syntax of a dictionary?

A

dictionary_name = {value:key, value:key, value:key}

21
Q

How do you print the value with a given key in a dictionary?

A

print(dictionary_name[key])

22
Q

How do you add value with a given key in a dictionary?

A

dictionary_name[New_Key] = New_Value

23
Q

How do you find if an element is in a list.

A

print(key in dictionary_name)

24
Q

What are the two identity operators?

A

is: evaluates if both sides have the same identity;

evaluates if both sides have different identities