exam 1 Flashcards

1
Q

A program receives data from a file, keyboard, touchscreen, network, etc.

A

Input

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

A program performs computations on that data, such as adding two values like x + y.

A

Process

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

A program puts that data somewhere, such as a file, screen, or network.

A

Output

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

A sequence of instructions that solves a problem

A

algorithm

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

A common way to become familiar with algorithms

A

turtle graphics

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

a program that allows the user to execute one line of code at a time.

A

interactive interpreter

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

a computer program that executes code written in the Python programming language.

A

Python interpreter

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

a common word for the textual representation of a program

A

Code

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

a row of text.

A

line

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

what is “»>” called?

A

prompt

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

a program instruction. A program mostly consists of a series of statements, and each statement usually appears on its own line.

A

statement

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

are code that return a value when evaluated

A

Expressions

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

A new variable is created by performing an _____ using the “=” symbol

A

assignment

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

function displays variables or expression values.

A

print()

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

Characters such as “#” denote

A

comments

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

Text enclosed in quotes is known as a ____. May have letters, numbers, spaces, or symbols like @ or #.

A

string literal

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

keeps the output of a subsequent print statement on the same line separated by a single space

A

end=’ ‘

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

Output can be moved to the next line by printing __ , known as a _______ .

A

“\n” , newline character

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

Any space, tab, or newline is called

A

whitespace

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

The function ______ causes the interpreter to wait until the user has entered text and pushed the return key.

A

input()

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

The input obtained by input() is any text that a user typed, including numbers, letters, or special characters such as # or @. Such text in a computer program is called a ____.

A

string

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

a ____ determines how a value can behave

A

type

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

violates a programming language’s rules on how symbols can be combined to create a program.

A

syntax error

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

a program’s syntax is correct but the program attempts an impossible operation

A

runtime error

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

Abrupt and unintended termination of a program is often called a

A

crash

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

The lines of the program are not properly indented.

A

Indentation Error

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

An invalid value is used, which can occur if giving letters to int().

A

Value Error

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

The program tries to use a variable that does not exist.

A

Name Error

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

An operation uses incorrect types, which can occur if adding an integer to a string.

A

Type Error

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

The program would load correctly but would not behave as intended. Such an error is known as a _______, because the program is logically flawed.

A

logic error

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

A logic error is often called a ___.

A

bug

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

An _________ assigns a variable with a value

A

assignment statement

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

a ____ is a named item

A

variable

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

Increasing a variable’s value by 1, as in x = x + 1, is common and known as_____ the variable.

A

incrementing

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

An ____, also called a name, is a sequence of letters (a-z, A-Z), underscores (_), and digits (0–9), and must start with a letter or an underscore.

A

identifier

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

______, or keywords, are words that are part of the language and cannot be used as a programmer-defined name.

A

Reserved words

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

outlines the basics of how to write Python code neatly and consistently

A

Python Enhancement Proposal (PEP 8)

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

A __________number is a real number. The term refers to the decimal point appearing anywhere in the number.

A

floating-point

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

is a data type for floating-point numbers.

A

float

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

A _____ is written with the fractional part even if that fraction is 0.

A

floating-point literal

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

A floating-point literal using ____ is written using an “e” preceding the power-of-10 exponent.

A

scientific notation

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

Assigning a floating-point value outside of this range generates an _____.

A

Overflow Error

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

occurs when a value is too large to be stored in the memory allocated by the interpreter.

A

Overflow

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

A ____ is a specific value in code

A

literal

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

An ____ is a symbol that performs a built-in calculation

A

operator

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

what is the exponent operator and in terms of x and y?

A

**, x to the power of y

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

An expression is evaluated using the order of standard mathematics, and is also known in programming as

A

precedence rules

48
Q

Items within parentheses are evaluated ____ .

A

first

49
Q

what is the order of precedence rules?

A

(), **, unary, * / % , + -, then left to right

50
Q

Minus (-) used as negative is known as ____.

A

unary minus

51
Q

Special operators called ____ provide a shorthand way to update a variable

A

compound operators

52
Q

A ____ is a conversion of one type to another, such as an integer to a float.

A

type conversion

53
Q

An ____ is a type conversion automatically made by the interpreter, usually between numeric types.

A

implicit conversion

54
Q

Creates integers and can convert integer, float, strings w/integers only

A

int()

55
Q

Creates floats and can convert integer, float, strings w/integers or fractions

A

float()

56
Q

Creates strings and can convert any type

A

str()

57
Q

The ____ evaluates the remainder of the division of two integer operands.

A

modulo operator or %

58
Q

A ____ is a file containing Python code that can be used by other modules or scripts and is Python code located in another file

A

module

59
Q

A module is made available for use via the ____.

A

import statement

60
Q

Once a module is imported, any object defined in that module can be accessed using ____.

A

dot notation

61
Q

Python comes with a standard ____ to support such advanced math operations.

A

math module

62
Q

A ____ is a list of statements that can be executed simply by referring to the function’s name.

A

function

63
Q

where does a programmer import a module?

A

top of the file

64
Q

The process of invoking a function is referred to as a ____.

A

function call

65
Q

what does floor() do?

A

Round-down value

66
Q

An ____ represents a value and is automatically created by the interpreter when executing a line of code.

A

object

67
Q

Deleting unused objects is an automatic process called ____ that frees memory space

A

garbage collection

68
Q

____ is the process of associating names with interpreter objects.

A

Name binding

69
Q

what are three defining properties each Python object has?

A

value, type, identity

70
Q

____ indicates whether the object’s value is allowed to be changed.

A

Mutability

71
Q

Integers and strings as objects are ____ ; meaning integer and string values cannot be changed.

A

immutable

72
Q

Python provides a built-in function ____ that gives the value of an object’s identity.

A

id()

73
Q

A ____ is a sequence of characters that can be stored in a variable.

A

string

74
Q

A ____ is a string value specified in the source code of a program.

A

string literal

75
Q

The string type is a special construct known as a ____: A type that specifies a collection of objects ordered from left to right.

A

sequence type

76
Q

The ____ built-in function can be used to find the length of a string (and any other sequence type).

A

len()

77
Q

A programmer can access a character at a specific index by appending ____containing the index

A

brackets or [ ]

78
Q

A program can add new characters to the end of a string in a process known as ____.

A

string concatenation

79
Q

A ____, or ____, allows a programmer to create a string with placeholder expressions that are evaluated as the program executes.

A

formatted string literal, f-string

80
Q

A placeholder expression is also called a ____, as its value replaces the expression in the final output.

A

replacement field

81
Q

A ____ inside a replacement field allows a value’s formatting in the string to be customized.

A

format specification

82
Q

A ____ is part of a format specification that determines how to represent a value in text form, such as an integer, a floating point, a fixed precision decimal, a percentage, a binary, etc.

A

presentation type

83
Q

A ____ is a construct used to group related values together and contains references to other objects instead of data.

A

container

84
Q

A ____ is a container created by surrounding a sequence of variables or literals with brackets [ ].

A

list

85
Q

A list item is called an ____.

A

element

86
Q

A list is also a sequence, meaning the contained elements are ordered by position in the list, known as the element’s ____ .

A

index

87
Q

A ____ instructs an object to perform some action, and is executed by specifying the method name following a “.” symbol and an object.

A

method

88
Q

The ____ list method is used to add new elements to a list.

A

append()

89
Q

Elements can be removed using the ____ or ____ methods.

A

pop(), remove()

90
Q

____ are built-in functions that operate on sequences like lists and strings.

A

Sequence-type functions

91
Q

____ are methods built into the class definitions of sequences like lists and strings.

A

Sequence-type methods

92
Q

A ____ stores a collection of data, like a list, but is immutable

A

tuple

93
Q

A ____ allows the programmer to define a new simple data type that consists of named attributes.

A

named tuple

94
Q

The ____ container must be imported to create a new named tuple.

A

namedtuple

95
Q

Because each memory location is composed of bits (0s and 1s), a processor stores a number using base 2, known as a ____ .

A

binary number

96
Q

The ____, in the Python Standard Library, provides methods that return random values.

A

random module

97
Q

The ____ method returns a random floating-point value each time the function is called, in the range 0 (inclusive) to 1 (exclusive).

A

random()

98
Q

Python’s ____ method generates random integers within a specified range.

A

randrange()

99
Q

The numbers generated by the random module are known as ____.

A

pseudo-random

100
Q

For the first call to any random method, no previous random number exists, so the method uses a built-in integer based on the current time, called a ____ , to help generate a random number.

A

seed

101
Q

In programming, an ____ is a grouping of data (variables) and operations that can be performed on that data (functions or methods)

A

object

102
Q

____ occurs when a user interacts with an object at a high level, allowing lower-level internal details to remain hidden

A

Abstraction

103
Q

An ____ is a data type whose creation and update are constrained to specific well-defined operations.

A

abstract data type (ADT)

104
Q

The ____ keyword can be used to create a user-defined type of object containing groups of related variables and functions.

A

class

105
Q

The object maintains a set of ____ that determines the data and behavior of the class.

A

attributes

106
Q

An ____ operation is performed by “calling” the class, using parentheses

A

instantiation

107
Q

An instantiation operation creates an ____, which is an individual object of the given class.

A

instance

108
Q

A ____ is a function defined within a class.

A

method

109
Q

The __init__ method, commonly known as a ____, is responsible for setting up the initial state of the new instance.

A

constructor

110
Q

Attributes can be accessed using the ____ “.”

A

attribute reference operator

111
Q

A function defined within a class is known as an
____.

A

instance method

112
Q

A ____ acts as a factory that creates instance objects.

A

class object

113
Q

A ____ is shared among all instances of that class. Class attributes are defined within the scope of a class.

A
114
Q

An ____ can be unique to each instance.

A
115
Q

A ____ consists of the methods that a programmer calls to create, modify, or access a class instance.

A

class interface

116
Q

____ is the process of defining how a class should behave for some common operations.

A

Class customization

117
Q

Class customization can redefine the functionality of built-in operators like <, >=, +, -, and * when used with class instances, a technique known as ____.

A

operator overloading