1/18
Looks like no tags are added yet.
a name paired with a value
variable
How do we assign a variable a value?
=
a = 4, b = 2, c = a * b
Variable Naming Conventions
Only contain ______, _____, & ______
First letter must be a _____or______
letters, numbers, and underscores
letter or underscore
Integer
whole number w/o decimal; positive, negative, or 0
Floats
number with decimal; positive, negative, or 0.0
Strings
sequence of any characters enclosed in quotation marks; treated like text
Booleans (bool)
True (1) or False (0); used for evaluating statement (is something true or false?)
type()
returns a variable’s data type
Ex: print(type(my_num)) —> <class ‘int’>
Different data types can be interconverted…with some important notes.
learn conversion rules b/w data types
Different data types can be interconverted…with some important notes.
learn conversion rules b/w data types
Mathematical operators
Function:
Ex: (7)
Function: allow you to carry out math operations
Ex: +, -, / (float division), *, ** (exponentiation), // (floor division), % (remainder/modulus),
If one or more numbers in a floor division operation is a float, the operation will return a _____.
float
Self-assignment
When a variable is declared and then reassigned to the variable via a calculation
Ex: my_var = 2 / my_var = my_var + 7 (my_var += 7)
Incrementing
Reassigning a variable to itself + 1
Ex: my_var += 1
3 Types of Logical Operators
Relational, Set, Boolean
Relational
checks relationship b/w variables
Ex: <, >, ==, <=, >=
Set
checks if a value is in a set
Ex: in
Boolean
And, Or, Not
String Comparisons
Strings are compared lexographically via ASCII
Oder: num < uppercase < lowercase
print(“3”<“THREE”<“three”) -> True
Review Truth Tables
Review Truth Tables