Python Flashcards
=
defines variable
==
testing if two things have the same value
\
prints \
\t*
indent and an asterisk
\a
ASCII Bell (BEL)
\b
ASCII Backspace (BS)
\f
ASCII Formfeed (FF)
\n
ASCII Linefeed (LF)
\N{name}
character named name in the Unicode database (Unicode only)
\r ASCII
Carriage Return (CR)
\t ASCII
Horizontal Tab (TAB)
\uxxxx
Character with 16-bit hex value xxxx (Unicode only)
\Uxxxxxxxx
Character with 32-bit hex value xxxxxxxx (Unicode only)
\v
ASCII Vertical Tab (VT)
\ooo
Character with octal value oo
\xhh
Character with hex value hh
def
keyword, indicates a function de?nition
**
exponentiation
- (strings)
repetition
value
One of the basic units of data, like a number or string, that a program manipulates.
type
A category of values. The types we have seen so far are integers (type int), ?oating-point numbers (type float), and strings (type str).
integer
A type that represents whole numbers.
floating-point
A type that represents numbers with fractional parts.
string
A type that represents sequences of characters.
variable
A name that refers to a value.
statement
A section of code that represents a command or action (assignment, print).
assignment
A statement that assigns a value to a variable.
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.
operator
A special symbol that represents a simple computation like addition, multiplication, or string concatenation.
operand
One of the values on which an operator operates.
floor division
The operation that divides two numbers and chops off the fraction part.
expression
A combination of variables, operators, and values that represents a single result value.
int
converts floating-point values to integers by chopping off the fraction part
float
converts integers and strings to ?oating-point numbers
str
converts its argument to a string
from math import pi
imports pi from math module
from math import *
imports everything from math module
function
A named sequence of statements that performs some useful operation. Functions may or may not take arguments and may or may not produce a result.
function definition (def)
A statement that creates a new function, specifying its name, parameters, and the statements it executes.
function object
A value created by a function de?nition. The name of the function is a variable that refers to a function object.
header
The ?rst line of a function de?nition.
body
The sequence of statements inside a function de?nition.
parameter
A name used inside a function to refer to the value passed as an argument
function call
A statement that executes a function. It consists of the function name followed by an argument list.
argument
A value provided to a function when the function is called. This value is assigned to the corresponding parameter in the function.
local variable
A variable de?ned inside a function. A local variable can only be used inside its function.
return variable
The result of a function. If a function call is used as an expression, the return value is the value of the expression.
fruitful function
A function that returns a value.
void function
A function that doesn’t return a value.
module
A ?le that contains a collection of related functions and other de?nitions.
import statement
A statement that reads a module ?le and creates a module object.
module object
A value created by an import statement that provides access to the values de?ned in a module.
dot notation
The syntax for calling a function in another module by specifying the module name followed by a dot (period) and the function name.
composition
Using an expression as part of a larger expression, or a statement as part of a larger statement.
flow of execution
The order in which statements are executed during a program run.
traceback
A list of the functions that are executing, printed when an exception occurs
state diagram
A graphical representation of a set of variables and the values they refer to.
stack diagram
A graphical representation of a stack of functions, their variables, and the values they refer to.
instance
a member of a set
loop
a part of a program that can execute repeatedly
encapsulation
The process of transforming a sequence of statements into a function de?nition.
generalization
The process of replacing something unnecessarily speci?c (like a number) with something appropriately general (like a variable or parameter).
keyword argument
An argument that includes the name of the parameter as a “keyword.” (in function call)
interface
A description of how to use a function, including the name and descriptions of the arguments and return value.
refactoring
The process of modifying a working program to improve function interfaces and other qualities of the code.
development plan
A process for writing programs.
docstring
A string that appears in a function de?nition to document the function’s interface.
precondition
A requirement that should be satis?ed by the caller before a function starts.
postcondition
A requirement that should be satis?ed by the function before it ends
x != y
x is not equal to y
modulus operator
An operator, denoted with a percent sign (%), that works on integers and yields the remainder when one number is divided by another.
boolean expression
An expression whose value is either True or False.
relational operator
One of the operators that compares its operands: ==, !=, >, =, <=.
logical operator
One of the operators that combines boolean expressions: and, or, not.
conditional statement
A statement that controls the ?ow of execution depending on some condition.
condition
The boolean expression in a conditional statement that determines which branch is executed.
compound statement
A statement that consists of a header and a body. The header ends with a colon (:). The body is indented relative to the header.
branch
One of the alternative sequences of statements in a conditional statement.
chained conditional
A conditional statement with a series of alternative branches.
nested conditional
A conditional statement that appears in one of the branches of another conditional statement.