Chapter 1 Variables, expressions, and statements Flashcards
assignment
A statement that assigns a value to a variable.
An assignment statement creates new variables and gives them values:
»> message = ‘And now for something completely different’
»> n = 17
»> pi = 3.1415926535897931
This example makes three assignments
The assignment statement produces no output.
concatenate
To join two operands end to end.
comment
Information in a program that is meant for other programmers (or anyone reading the source code) and has no effect on the execution of the program.
comment
Information in a program that is meant for other programmers (or anyone reading the source code) and has no effect on the execution of the program.
evaluate
To simplify an expression by performing the operations (in order of precedence) in order to yield a single value.
expression
A combination of variables, operators, and values that represents a single result value.
floating point
A type that represents numbers with fractional parts.
/ for floating point division
integer
A type that represents whole numbers.
// for integer division
keyword
A reserved word that is used by the compiler to parse a program; you cannot use keywords like if, def, and while as variable names.
Python reserves 35 keywords:
False await else import pass
None break except in raise
True class finally is return
and continue for lambda try
as def from nonlocal while
assert del global not with
async elif if or yield
mnemonic
PEMDAS
A memory aid. We often give variables mnemonic names to help us remember what is stored in the variable.
PEMDAS for operators order of precedence in Python
modulus operator
An operator, denoted with a percent sign (%), that works on integers and yields the remainder when one number is divided by another.
operand
One of the values on which an operator operates.
operator
A special symbol that represents a simple computation like addition, multiplication, or string concatenation.
rules of precedence
The set of rules governing the order in which expressions involving multiple operators and operands are evaluated.
P
E
M, D
A, S
statement
A section of code that represents a command or action. So far, the statements we have seen are assignments and print expression statement.