Data Types and Arithmetic Flashcards

1
Q

Give the data type and description of integers.

A

int; whole #s

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

Give the data type and description of floating points.

A

float; any decimal number, 2.3, 4.6, 100.0

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

Give the data type and description of strings.

A

str; “hello”, ‘Sammy’, “2000”.

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

Give the data type and description of list.

A

list; Ordered mutable sequence of objects, [ 10, “hello”, 200.3]

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

Give the data type and description of dictionaries.

A

dict; Unordered key: value pairs: {“mykey”: “value”, “name” : “Frankie”}.

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

Give the data type and description of tuples.

A

tup; Ordered immutable sequence of objects: (10, “hello”, 200.3).
immutable - unchanging over time or unable to be changed.

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

Give the data type and description of sets.

A

set; Unordered collection of unique objects: {“a”, “b”}.

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

Give the data type and description of booleans.

A

bool; Logical value indicating TRUE or FALSE.

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

What operator can be used to find the remainder of a quotient.

A

Mod operator, %.
Syntax:
In: 7%4
Out: 3

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

Give the syntax of the power operator, say 2 cubed.

A

Syntax: 2**3.

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

Why is this a false statement 0.1 + 0.2 - 0.3 = 0.0 in python?

A

This has to do with floating point accuracy and the computer’s abilities to represent numbers in memory.

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

Python is known to have dynamic typing. What does this mean?

A
A variable can be redefined multiple times with no errors given from python. 
In:    a = 5
In:    a = 10
In:    a + a
Out: 20.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Scenario: You want to know what type of data type a variable is. What can be done?

A

In: type(variable)
Out: type

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