THINK Python Flashcards
Program
a sequence of instructions that specifies how to perform a computation. The computation might be something mathematical, such as solving a system of equations or finding the roots of a polynomial, but it can also be a symbolic computation, such as search- ing and replacing text in a document or something graphical, like processing an image or playing a video.
Input
Get data from the keyboard, a file, the network, or some other device.
Output
Display data on the screen, save it in a file, send it over the network, etc.
Math
Perform basic mathematical operations like addition and multiplication.
Conditional Execution
Check for certain conditions and run the appropriate code.
Repetition
Perform some action repeatedly, usually with some variation.
High-Level Language
A programming language like Python that is designed to be easy for humans to read and write.
Low-Level Language
A programming language that is designed to be easy for a computer to run; also called “machine language” or “assembly language”.
Portability
A property of a program that can run on more than one kind of computer.
Interpreter
A program that reads another program and executes it
Prompt
Characters displayed by the interpreter to indicate that it is ready to take input from the user.
Print Statement
An instruction that causes the Python interpreter to display a value on
the screen.
Operator
A special symbol that represents a simple computation like addition, multipli- cation, or string concatenation.
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), floating-
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.
Formal Language
Any one of the languages that people have designed for specific purposes, such as representing mathematical ideas or computer programs; all program- ming languages are formal languages.
Token
One of the basic elements of the syntactic structure of a program, analogous to a word in a natural language.
Syntax
The rules that govern the structure of a program.
Parse
To examine a program and analyze the syntactic structure.
Bug
An error in a program.
Debugging
The process of finding and correcting bugs.
Variable
A name that refers to a value.
Assignment
A statement that assigns a value to a variable.
Keyword
A reserved word that is used to parse a program; you cannot use keywords like if, def, and while as variable names.
Operand
One of the values on which an operator operates.
Expression
A combination of variables, operators, and values that represents a single result.
Statement
A section of code that represents a command or action. So far, the statements we have seen are assignments and print statements.
Execute
To run a statement and do what it says.
Interactive Mode
A way of using the Python interpreter by typing code at the prompt.
Script Mode
A way of using the Python interpreter to read code from a script and run it.
Script
A program stored in a file.
Concatenate
To join two operants end to end.
Comment
Informationinaprogramthatismeantforotherprogrammers(oranyoneread-
ing the source code) and has no effect on the execution of the program.
Syntax Error
An error in a program that makes it impossible to parse (and therefore im- possible to interpret).
Exception
An error that is detected while the program is running.
Semantics
The meaning of a program.
Semantic Error
An error in a program that makes it do something other than what the programmer intended.
Method
A function that is associated with an object and called using dot notation.
Loop
A part of a program that can run repeatedly.
Encapsulation
The process of transforming a sequence of statements into a function definition.
Generalization
The process of replacing something unnecessarily specific (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”. page 33
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.
page 35
Docstring
A string that appears at the top of a function definition to document the function’s interface.
Precondition
A requirement that should be satisfied by the caller before the function starts.
page 36
Postcondition
A requirement that should be satisfied by the function before it ends.
page 36
Floor Division
//
Divides two numbers and rounds DOWN to the nearest integer.
Modulus Operator
%
Divides two numbers and returns the remainder.
Boolean Expression
An expression that is either True or False.
Relational Operator
One of the operators that compares its operands: ==, !=, >, <, >=, and <=.
Logical Operator
One of the operators that combines boolean expressions: and, or, not.
Conditional Statement
A statement that controls the flow of execution depending on some condition.
Condition
A boolean expression in a conditional statement that determines which branch runs.