Python Basic Flashcards
Exponent Operator and example
**
2**3 = 8
Modulus/remainder operator and example
%
7%5 = 2
Integer division/floored quotient operator and example
// 12//5 = 2
Division operator and example
/
12/5=2.4
Multiplication operator and example
*
2*5=10
Subtraction operator and example
-
5-2=3
Addition operator and example
+
5+2=7
What is the order of operations (also called precedence) of Python math operators?
** % // / * - \+
What are expressions?
values combined with operators, and they always evaluate down to a single value
What are the most common data type in python?
integers = -2, 5, 6
Floating-point numbers(float) = 2.44
strings = a, b ,c
What does it mean?
SyntaxError: EOL while scanning string literal
you probably forgot the final single quote character at the end of the string
EOL stands for end of line
What is the string concatenation operator?
+
‘Bob’ + ‘ ‘ + ‘ Dylan’
Bob Dylan
What does it mean?
TypeError: can only concatenate str (not “int”) to str
‘Bob’ + 25
we cannot use + to concatenate strings and integers
What is string replication operator?
‘Bob’*5 (this should be a value, it cannot be a string)
‘BobBobBobBobBob’
What is an assignment statement?
Spam = 25
variable name, an equal sign (called the assignment operator), and the value to be stored