Fundamentals: Program Vocab Flashcards
Expression
A unit of code that can be evaluated into one value.
Used in a sentence:
“The expression 999 > 0 is True!” “We use the expression 999 > 0 to determine if our code prints “Hello!”,” “While I’m debugging, I need to keep checking what the expression total_price * 1.1 evaluates into”
In programming, an expression is a unit of code that can be evaluated into one value.
We use expressions mainly to get a value.
Statement
A unit of code that is used to execute a change
Variable
A name that is a reference to a specific place in memory, and the value stored there. Variables can be assigned and reassigned values.
Literal
A value that is the value itself.
Integer
Represents an integer! A whole number that is positive, negative, or zero.
Float
Represents a number that isn’t whole; it is fractional, or has a decimal place.
String
Represents text, specifically with an ordered sequence of characters.
Boolean
Represents true or false.
List
An ordered list of values. Items in the list are sometimes called elements. Can get the value of an item by using square brackets and the index of the item.
Dictionary
An unordered collection of key-value pairs. Can access values in the dictionary by using square brackets and the name of the key.
Range
A sequence of numbers between a start, stop, and incrementing by a step.
Tuple
An ordered, unchangeable collection of items.
Set, frozenset
An unordered collection. Cannot access values with index or key; must use a loop.
bytes, bytearray
A collection of binary digits (bits).
Get the Data Type with type()
If we’re ever unsure about what the data type of a value is, we can use Python’s built-in method type() to read the data type.
print(type(“This is a string!”))
print(type(6789 * 100))
print(type(3.3))
print(type([“do”, “re”, “mi”]))
my_bicycle_details = { "frame_color": "red", "num_of_wheels": 2, "grip_tape_color": "turquoise" } print(type(my_bicycle_details)) print(type(my_bicycle_details["num_of_wheels"]))
PRINTS OUT: