Data Types Flashcards

1
Q

What will the following expression evaluate to?

bool((5-5))

A

IT would equal false since 5-5=0 and zero equals false

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

What will the following expression evaluate to?

bool(1-1) == bool(0)

A

it would equal 0 which 0=0 is true

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

What will the code below output?

value = "500"
print('The value',
value,
'divided by 5 equals',
int(value)/5)
A

it would output
The value 500 divided by 5 equals 100.0

it does the .0 because a single division sign it will automatically assume it will have a remainder

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

The built-in ______ function returns a unique identifier of an object that is referenced by a particular variable

A

id()

keyword is identifier

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

Maximum values for integers are inherently limited by the Python interpreter at runtime.

A

False
Python3 does not limit the maximum value of an integer, it is unbounded. Unbounded is a mathematical term for functions and values that have no maximum value.

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

An integer in defined in Python by using the reserved keyword int

A

True

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

An unbounded integer is an iteger whos value is dependent on the interpereter at runtime.

A

False
Unbounded is a mathematical term for functions and values that have no maximum value.
The size of the integer is limited to the size of the registers/memory allocated to the integer within the operating system

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

Strings are immutable, which means they cannot be changed once theyre created in memory.

A

False.
Per the slides
A Python expert would describe strings as an “immutable sequence of zero or more characters.”
Immutable, in that strings cannot be changed once created.

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

Using the multiplication operator with a string and an integer results in the string being repeated as many times as the integer’s value.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
a = 5
b = 10
c = 15
x = a + b
y = x - c
z = y-x+c

z = bool(z)
print(z)

A

so x= 15 then y = 0 then z=30 but 30 is not one or a zero so it is false as a boolean value

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