Chapter 3 Flashcards
(38 cards)
Comment
A line of code written in English preceded by #
print(“”) or print(‘’)
Prints whatever character input between the parenthesis
Line
Programs are made up of lines of code.
Keywords
Words with special meaning.
Data Types
Python groups data into different categories.
Object
Each data value. ie. 2 or “Hello, world!”
3 Properties of an Object
- Identity
- Data Type
- Value
Object’s Identity
Location in your computer’s memory, which never changes.
Object’s Data Type
Category of data the object belongs to, which determines the properties of the object, which never changes.
Object’s Value
The data it represents ie. the number 2. Value of 2.
“Hello, world!” Object Properties
- Data Type: str == string
- Value: “Hello, world!”
aka a string
string
A sequence of one or more characters surrounded by quotes.
character
A single symbol. ie. ‘a’ or ‘1’.
Integer
int;
represents whole numbers
int Properties
Able to multiply(*), divide(/), add(+), subtract(-).
float
float;
represents decimal numbers
booleans
bool;
True or False statements.
NoneType
value None;
Used to represent the absence of value.
Constant
Value that never changes.
eg. 2 will always represent the value 2
Variable
Value that can change.
eg. b = 100; b = 200
Assignment Operator
(=);
Assign the variables name a value.
Increment Value of a Variable
Increases the value of a variable.
eg. x = x + 1 or x = x += 1
Decrement Value of a Variable
Decreases the value of a variable.
eg. x = x - 1 or x -= 1
4 Rules for Naming a Variable
- Variables cannot have spaces.
- Letters, numbers, and underscore.
- Cannot start name with a number.
- Cannot use keywords as names.