THINK Python Flashcards

(147 cards)

1
Q

Program

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Input

A

Get data from the keyboard, a file, the network, or some other device.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Output

A

Display data on the screen, save it in a file, send it over the network, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Math

A

Perform basic mathematical operations like addition and multiplication.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Conditional Execution

A

Check for certain conditions and run the appropriate code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Repetition

A

Perform some action repeatedly, usually with some variation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

High-Level Language

A

A programming language like Python that is designed to be easy for humans to read and write.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Low-Level Language

A

A programming language that is designed to be easy for a computer to run; also called “machine language” or “assembly language”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Portability

A

A property of a program that can run on more than one kind of computer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Interpreter

A

A program that reads another program and executes it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Prompt

A

Characters displayed by the interpreter to indicate that it is ready to take input from the user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Print Statement

A

An instruction that causes the Python interpreter to display a value on
the screen.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Operator

A

A special symbol that represents a simple computation like addition, multipli- cation, or string concatenation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Value

A

One of the basic units of data, like a number or string, that a program manipulates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Type

A

A category of values. The types we have seen so far are integers (type int), floating-
point numbers (type float), and strings (type str).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Integer

A

A type that represents whole numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Floating-Point

A

A type that represents numbers with fractional parts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

String

A

A type that represents sequences of characters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Formal Language

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Token

A

One of the basic elements of the syntactic structure of a program, analogous to a word in a natural language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Syntax

A

The rules that govern the structure of a program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Parse

A

To examine a program and analyze the syntactic structure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Bug

A

An error in a program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Debugging

A

The process of finding and correcting bugs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Variable
A name that refers to a value.
26
Assignment
A statement that assigns a value to a variable.
27
Keyword
A reserved word that is used to parse a program; you cannot use keywords like if, def, and while as variable names.
28
Operand
One of the values on which an operator operates.
29
Expression
A combination of variables, operators, and values that represents a single result.
30
Statement
A section of code that represents a command or action. So far, the statements we have seen are assignments and print statements.
31
Execute
To run a statement and do what it says.
32
Interactive Mode
A way of using the Python interpreter by typing code at the prompt.
33
Script Mode
A way of using the Python interpreter to read code from a script and run it.
34
Script
A program stored in a file.
35
Concatenate
To join two operants end to end.
36
Comment
Informationinaprogramthatismeantforotherprogrammers(oranyoneread- ing the source code) and has no effect on the execution of the program.
37
Syntax Error
An error in a program that makes it impossible to parse (and therefore im- possible to interpret).
38
Exception
An error that is detected while the program is running.
39
Semantics
The meaning of a program.
40
Semantic Error
An error in a program that makes it do something other than what the programmer intended.
41
Method
A function that is associated with an object and called using dot notation.
42
Loop
A part of a program that can run repeatedly.
43
Encapsulation
The process of transforming a sequence of statements into a function definition.
44
Generalization
The process of replacing something unnecessarily specific (like a number) with something appropriately general (like a variable or parameter).
45
Keyword Argument
An argument that includes the name of the parameter as a "keyword". page 33
46
Interface
A description of how to use a function, including the name and descriptions of the arguments and return value.
47
Refactoring
The process of modifying a working program to improve function interfaces and other qualities of the code.
48
Development Plan
A process for writing programs. page 35
49
Docstring
A string that appears at the top of a function definition to document the function's interface.
50
Precondition
A requirement that should be satisfied by the caller before the function starts. page 36
51
Postcondition
A requirement that should be satisfied by the function before it ends. page 36
52
Floor Division
// Divides two numbers and rounds DOWN to the nearest integer.
53
Modulus Operator
% Divides two numbers and returns the remainder.
54
Boolean Expression
An expression that is either True or False.
55
Relational Operator
One of the operators that compares its operands: ==, !=, >, <, >=, and <=.
56
Logical Operator
One of the operators that combines boolean expressions: and, or, not.
57
Conditional Statement
A statement that controls the flow of execution depending on some condition.
58
Condition
A boolean expression in a conditional statement that determines which branch runs.
59
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.
60
Branch
One of the alternative sequences of statements in a conditional statement.
61
Chained Conditional
A conditional statement with a series of alternative branches.
62
Nested Conditional
A conditional statement that appears in one of the branches of another conditional statement.
63
Return Statement
A statement that causes a function to end immediately and return to the caller.
64
Recursion
The process of calling the function that is currently executing.
65
Base Case
A conditional branch in a recursive function that does not make a recursive call.
66
Infinite Recursion
A recursion that does not have a base case, or never reaches it. Eventually, an infinite recursion causes a runtime error.
67
_ _ main_ _
(page 23) A special name fr the topmost frame. When you create a variable outside of any function, it belongs to __main__.
68
Temporary Variable
A variable used to store an intermediate value in a complex calculation.
69
Dead Code
Part of a program that can never run, often because it appears after a return statement. e.g. alternative conditionals
70
Incremental Development
A program development plan intended to avoid debugging by adding and testing only a small amount of code at a time.
71
Scaffolding
Code that is used during program development but is not part of the final version.
72
Guardian
A programming pattern that uses a conditional statement to check for and handle circumstances that might cause an error.
72
Update
An assignment where the new value of the variable depends on the old. e.g. x = x + 1 which means " get the value of x, add one, and then update the value of x with the new value"
72
Reassignment
Assigning a new value to a variable that already exists.
72
Increment
An update that increases the value of a variable (often by one).
73
Object
Something a variable can refer to. For now (chapter 8), you can use "object" and "value" interchangeably.
73
Iteration
Repeated execution of a set of statements using either a recursive function or a loop.
73
Initialization
As assignment that gives an initial value to a variable that will be updated.
73
Decrement
An update that decreases the value of a variable.
73
Infinite Loop
A loop in which the terminating condition is never satisfying.
73
what is the flow of execution for a while loop?
1. Determine whether the condition is true or false. 2. If false, exit the while loop and continue execution at the next step. 3. If the condition is true, run the body and then go back to step 1.
74
Algorithm
A general process for solving a category of problems.
75
Sequence
An ordered collection of values where each value is identified by an integer index. A string is a sequence.
76
Item
One of the values in a sequence.
77
Index
An integer value used to select an item in a sequence, such as a character in a string. In Python, indices start at 0.
78
Slice
A part of a string specified by a range of indices.
79
Empty String
A string with no characters and length 0, represented by two quotation marks.
80
Immutable
The property of a sequence whose items cannot be changed.
81
Traverse
To iterate through the items in a sequence, performing a similar operation on each.
82
Search
A pattern of traversal that stops when it finds what its looking for.
83
Counter
A variable used to count something, usually initially at 0 and then incremented.
84
Invocation
A statement that calls a method.
85
Optional Argument
A function or method argument that is not required.
86
what are some examples of string methods?
1) .upper() 2) .find()
87
File Object
A value that represents an open file.
88
Reduction to a Previously Solved Problem
A way of solving a problem by expressing it as an instance of a previously solved problem.
89
Special Case
A test case that is atypical or non-obvious (and less likely to be handled correctly).
90
List
A sequence of values.
91
Element
One of the values in a list (or other sequence), also called items.
92
Nested List
A list that is an element of another list.
93
Accumulator
A variable used in a loop to add up or accumulate a result.
94
Augmented Assignment
A statement that updates the value of a variable using an operator like +=.
95
Reduce
A processing pattern that traverses a sequence and accumulates the elements into a single result.
96
Map
A processing pattern that traverses a sequence and performs an operation on each element.
97
Filter
A processing pattern that traverses a list and selects the elements that satisfy some criterion.
98
Object
Something a variable can refer to. An object has a type and a value.
99
Equivalent
Having the same value.
100
Identical
Being the same object (which implies equivalence).
101
Reference
The association between a variable and its value.
102
Aliasing
A circumstance where two or more variables refer to the same object.
103
Delimiter
A character or string used to indicate where a string should be split.
104
range function
built-in python function. range returns a list of indices from 0 to n-1, where n is the length of the list.
105
List Operations
The + operator concatenates lists. The * operator repeats a list a given number of times.
106
List Methods
append - adds a new element to the end of a list. extend - takes a list as an argument and appends all the elements. sort - arranges the elements in a list from low to high. .sorted() - returns a new sorted list and leaves the original alone
107
ways to delete elements from strings
1) pop() 2) del 3) remove()
108
Caller
The caller of a function is the unit of program code in which the call to the function occurred. This can be another function, a method (a specific type of function) or, in Python, the code in the "top level" of a python source code file -- generally referred to as a script. (stack overflow)
109
Floor Division
supported in python. using // instead of / returns the integer value of a quotient. it drops anything after the decimal. Definition: Floor division is a division operation that rounds the result down to the nearest whole number or integer, which is less than or equal to the normal division result. The floor function is mathematically denoted by this ⌊ ⌋ symbol.
110
mapping (chapter 11)
a relationship in which each element of one set corresponds to an element of another set.
111
dictionary
a mapping from keys to their corresponding values.
112
Key-Value pair
the representation of the mapping from a key to a value.
113
Item
In a dictionary, another name for a key-value pair.
114
Key
An object that appears in a dictionary as the first part of a key-value pair.
115
Value (chapter 11)
An object that appears in a dictionary as the second part of a key-value pair. This is more specific than our previous use of the word value.
116
Implementation
A way of performing a computation.
117
Hashtable
The algorithm used to implement Python dictionaries.
118
Hash Function
A function used by a hashtable to compute the location for a key.
119
Hasable
A type that has a hash function. Immutable types like integers, floats, and strings are hashable; mutable types like lists and dictionaries are not.
120
Lookup
A dictionary operation that takes a key and finds the corresponding value.
121
Reverse Lookup
A dictionary operation that takes a value and finds one or more keys that map to it.
122
Raise Statement
A statement that (deliberately) raises an exception.
123
Singleton
A list (or other sequence) with a single element.
124
Call graph
A diagram that shows every frame created during the execution of a program, with an arrow from each caller to each callee.
125
Memo
A computed value stored to avoid unnecessary future computation.
126
Global Variable
A variable defined outside a function. Global variables can be accessed from any function.
127
Global Statement
A statement that declares a variable name global.
128
Flag
A boolean variable used to indicate whether a condition is true.
129
Declaration
A statement like "global" that tells the interpreter something about a variable.
130
get method
Dictionaries have a method called "get" that takes a key and a default value. If the key appears in the dictionary, "get" returns the corresponding value; otherwise it returns the default value.
131
Tuple
An immutable sequence of elements.
132
Tuple Assignment
An assignment with a sequence on the right side and a tuple of variables on the left. The right side is evaluated and then its elements are assigned to the variables on the left.
133
Gather
An operation that collects multiple arguments into a tuple. "*"
134
Scatter
An operation that makes a sequence behave like multiple arguments.
135
Zip Object
The result of calling a built-in function "zip"; an object that iterates through a sequence of tuples.
136
Iterator (chapter 12)
An object that can iterate through a sequence, but which does not provide list operators and methods.
137
Data Structure
A collection of related values, often organized in lists, dictionaries, tuples, etc.
138
Shape Error
An error caused because a value has the wrong shape; that is, the wrong type or size.
139