Data Types and Arithmetic Flashcards
Give the data type and description of integers.
int; whole #s
Give the data type and description of floating points.
float; any decimal number, 2.3, 4.6, 100.0
Give the data type and description of strings.
str; “hello”, ‘Sammy’, “2000”.
Give the data type and description of list.
list; Ordered mutable sequence of objects, [ 10, “hello”, 200.3]
Give the data type and description of dictionaries.
dict; Unordered key: value pairs: {“mykey”: “value”, “name” : “Frankie”}.
Give the data type and description of tuples.
tup; Ordered immutable sequence of objects: (10, “hello”, 200.3).
immutable - unchanging over time or unable to be changed.
Give the data type and description of sets.
set; Unordered collection of unique objects: {“a”, “b”}.
Give the data type and description of booleans.
bool; Logical value indicating TRUE or FALSE.
What operator can be used to find the remainder of a quotient.
Mod operator, %.
Syntax:
In: 7%4
Out: 3
Give the syntax of the power operator, say 2 cubed.
Syntax: 2**3.
Why is this a false statement 0.1 + 0.2 - 0.3 = 0.0 in python?
This has to do with floating point accuracy and the computer’s abilities to represent numbers in memory.
Python is known to have dynamic typing. What does this mean?
A variable can be redefined multiple times with no errors given from python. In: a = 5 In: a = 10 In: a + a Out: 20.
Scenario: You want to know what type of data type a variable is. What can be done?
In: type(variable)
Out: type