Section 1

Preview this deck

immutable type

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

12

All-time users

13

Favorites

0

Last updated

4 years ago

Date created

Mar 14, 2020

Cards (565)

Section 1

(50 cards)

immutable type

Front

A compound data type whose elements can NOT be assigned new values.

Back

function

Front

A named sequence of statements that performs some useful operation. Functions may or may not take parameters and may or may not produce a result

Back

boolean expression

Front

An expression that is either true or false.

Back

compound data type

Front

A data type that is itself made up of elements that are themselves values.

Back

evaluate

Front

To simplify an expression by performing the operations in order to yield a single value.

Back

iteration

Front

Repeated execution of a set of programming statements.

Back

mutable type

Front

A compound data type whose elements can be assigned new values.

Back

operator

Front

A special symbol that represents a simple computation like addition, multiplication, or string concatenation.

Back

boolean function

Front

A function that returns a Boolean value. The only possible values of the bool type are False and True.

Back

global variable

Front

Can be seen through a program module, even inside of functions.

Back

pixel

Front

Smallest addressable element of a picture.

Back

flow of execution

Front

The order in which statements are executed during a program run.

Back

slice

Front

A copy of part of a sequence specified by a series of indices.

Back

fruitful function

Front

A function that returns a value when it is called.

Back

operators

Front

special tokens that represent computations like addition, multiplication and division

Back

conditional statement

Front

One program structure within another, such as a conditional statement inside a branch of another conditional statement

Back

format operator

Front

The % operator takes a format string and a tuple of values and generates a string by inserting the data values into the format string at the appropriate locations.

Back

None

Front

A special Python value. One use in Python is that it is returned by functions that do not execute a return statement with a return argument.

Back

float

Front

A Python data type which stores floating-point numbers. Floating-point numbers are stored internally in two parts: a base and an exponent. When printed in the standard format, they look like decimal numbers

Back

local variable

Front

A variable defined inside a function. A local variable can only be used inside its function. Parameters of a function are also a special kind of local variable.

Back

modulus operator

Front

%, works on integers (and integer expressions) and gives the remainder when the first number is divided by the second

Back

short circuit evaluation

Front

When a boolean expression is evaluated the evaluation starts at the left hand expression and proceeds to the right, stopping when it is no longer necessary to evaluate any further to determine the final outcome.

Back

parameter

Front

A name used inside a function to refer to the value which was passed to it as an argument.

Back

proprioception

Front

on a robot, internal sensing mechanisms. On a human, a sense of the relative positions of different parts of ones own body.

Back

type conversion

Front

An explicit function call that takes a value of one type and computes a corresponding value of another type.

Back

conditional statement

Front

A statement that controls the flow of execution depending on some condition. In Python the keywords if, elif, and else are used for conditional statements.

Back

robot

Front

mechanism or an artificial entity that can be guided by automatic controls.

Back

increment

Front

Both as a noun and as a verb, increment means to increase by 1.

Back

token

Front

basic elements of a language(letters, numbers, symbols)

Back

decrement

Front

To subtract one from a variable.

Back

nested loop

Front

A loop inside the body of another loop.

Back

statement

Front

instruction that the Python interpreter can execute

Back

high-level language

Front

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

Back

trace

Front

To follow the flow of execution of a program by hand, recording the change of state of the variables and any output produced.

Back

int

Front

A Python data type that holds positive and negative whole numbers

Back

keyword

Front

define the language's syntax rules and structure, and they cannot be used as variable names

Back

dictionary

Front

A collection of key/value pairs that maps from keys to values.

Back

algorithm

Front

A set of specific steps for solving a category of problems

Back

file

Front

A named entity, usually stored on a hard drive, floppy disk, or CD-ROM, that contains a stream of characters.

Back

iteration

Front

To repeat a section of code.

Back

exception

Front

Raised by the runtime system if something goes wrong while the program is running.

Back

traverse

Front

To repeat an operation on all members of a set from the start to the end.

Back

clone

Front

To create a new object that has the same value as an existing object. Copying a reference to an object creates an alias but doesn't clone the object.

Back

sequence

Front

A data type that is made up of elements organized linearly, with each element accessed by an integer index.

Back

aliases

Front

Multiple variables that contain references to the same object.

Back

block

Front

A group of consecutive statements with the same indentation.

Back

recursion

Front

The process of calling the currently executing function.

Back

low-level langauge

Front

A programming language that is designed to be easy for a computer to execute; also called machine language or assembly language

Back

definite iteration

Front

A loop where we have an upper bound on the number of times the body will be executed. Definite iteration is usually best coded as a for loop

Back

nested list

Front

A list that is itself contained within a list.

Back

Section 2

(50 cards)

lambda

Front

A piece of code which can be executed as if it were a function but without a name. (It is also a keyword used to create such an anonymous function.)

Back

Which of the following is not a microprocessor manufacturing company?

Front

Dell

Back

What type of loop structure repeats the code based on the value of the Boolean expression

Front

Condition-controlled loop

Back

True/False: Both of the following for clauses would generate the same number of loop iterations: for num in range(4): for num in range(1,5):

Front

False

Back

True/False: The CPU is able to quickly access data stored at any random location in ROM.

Front

False

Back

True/False: The integrity of a program's output is only as good as the integrity of its input. For this reason the program should discard input that is invalid and prompt the user to enter correct data.

Front

True

Back

True/False: In a nested loop, the inner loop goes through all of its iterations for every single iteration of an outer loop.

Front

True

Back

What is the structure that causes a statement or a set of statements to execute repeatedly?

Front

Repetition

Back

The following is an example of an instruction written in which computer language? 10110000

Front

Machine language

Back

In Python, the variable in the for clause is referred to as the _____ because it is the target of an assignment at the beginning of each loop iteration.

Front

Target Variable

Back

A(n) ??-controlled loop causes a statement or set of statements to repeat as long as a condition is true.

Front

Condition

Back

In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called a _____.

Front

list

Back

What is the largest value that can be stored in one byte?

Front

255

Back

integer division

Front

An operation that divides one integer by another and yields an integer. Integer division yields only the whole number of times that the numerator is divisible by the denominator and discards any remainder.

Back

A(n) ?? is a special value that marks the end of a sequence of items.

Front

Sentinel

Back

True/False: A better way to repeatedly perform an operation is to write the statements for the task once, and then place the statements in a loop that will repeat the statements as many times as necessary.

Front

True

Back

A(n) ?? validation loop is sometimes called an error trap or an error handler.

Front

Input

Back

The variable used to keep the running total

Front

Accumulator

Back

The while loop is known as a(n) ?? loop because it tests conditions before performing an iteration.

Front

Pretest

Back

In Python, you would use the ?? statement to write a count-controlled loop.

Front

For

Back

True/False: A computer is a single device that performs different types of tasks for its users.

Front

False

Back

The acronym ?? refers to the fact that the computer cannot tell the difference between good data and bad data.

Front

GIGO

Back

What is the format for the while clause in Python

Front

while condition : statement

Back

True/False: In flowcharting, the decision structure and the repetition structure both use the diamond symbol to represent the condition that is tested.

Front

True

Back

What is the encoding technique called that is used to store negative numbers in the computer's memory?

Front

two's complement

Back

The ?? function is a built-in function that generates a list of integer values.

Front

Range

Back

argument

Front

a value provided to a function when the function is called. This value is assigned to the corresponding parameter in the function.

Back

What are the values that the variable num contains through the iterations of the following for loop? for num in range(4)

Front

0, 1, 2, 3

Back

The _____ coding scheme contains a set of 128 numeric codes that are used to represent characters in the computer memory.

Front

ASCII

Back

What is the disadvantage of coding in one long sequence structure?

Front

If parts of the duplicated code have to be corrected, the correction has to be made many times.

Back

Which of the following represents an example to calculate the sum of the numbers (accumulator)?

Front

total += number

Back

When will the following loop terminate? while keep_on_going != 999 :

Front

When keep_on_going refers to a value not equal to 999

Back

The first input operation is called the _____, and its purpose is to get the first input value that will be tested by the validation loop.

Front

Priming read

Back

True/False: In Python, an infinite loop usually occurs when the computer accesses the wrong memory address.

Front

False

Back

A(n) ?? total is a sum of numbers that accumulates with each iteration of a loop.

Front

Running

Back

What type of loop structure repeats the code a specific number of times

Front

Count-controlled loop

Back

A _____ has no moving parts, and operates faster than a traditional disk drive.

Front

solid state drive

Back

A(n) ?? structure causes a statement or set of statements to execute repeatedly.

Front

Repetition

Back

True/False: The first line in the while loop is referred to as the condition clause.

Front

True

Back

element

Front

One of the values in a list (or other sequence). The bracket operator selects elements of a list.

Back

The disk drive is a secondary storage device that stores data by _____ encoding it onto a spinning circular disk.

Front

magnetically

Back

True/False: All programs are normally stored in ROM and loaded into RAM as needed for processing.

Front

False

Back

The smallest storage location in a computer's memory

Front

bit

Back

True/False: To get the total number of iterations of a nested loop, multiply the number of iterations of all the loops.

Front

True

Back

What is not an example of an augmented assignment operator

Front

<=

Back

Which computer language uses short words known as mnemonics for writing programs?

Front

Assembly

Back

What are the values that the variable num contains through the iterations of the following for loop? for num in range(2, 9, 2)

Front

2, 4, 6, 8

Back

_____ is the process of inspecting data that has been input to a program to make sure it is valid before it is used in a computation.

Front

Input validation

Back

The process known as the _____ cycle is used by the CPU to execute instructions in a program.

Front

fetch-decode-execute

Back

module

Front

A file containing definitions and statements intended to be imported by other programs.

Back

Section 3

(50 cards)

True/False: The if statement causes one or more statements to execute only when a Boolean expression is true.

Front

True

Back

A(n) _______________ is a name that represents a value stored in the computer's memory.

Front

variable

Back

True/False: Computer programs typically perform three steps: Input is received, some process is performed on the input, and output is produced.

Front

True

Back

When the + operator is used with two strings, it performs string _______________.

Front

Concatenation

Back

True/False: The main reason for using secondary storage is to hold data for long periods of time, even when the power supply to the computer is turned off.

Front

True

Back

The line continuation character is a _____.

Front

\

Back

What is the informal language that programmers use to create models of programs that have no syntax rules and are not meant to be compiled or executed?

Front

pseudocode

Back

What is the output of the following print statement? print('The path is D:\\sample\\test.')

Front

The path is D:\sample\test

Back

Multiple Boolean expressions can be combined by using a logical operator to create _____ expressions.

Front

compound

Back

The % symbol is the remainder operator and it is also known as the _______________ operator.

Front

modulus

Back

In _______________ mode, the interpreter reads the contents of a file that contains Python statements and executes each statement.

Front

script

Back

True/False: RAM is a volatile memory used for temporary storage while a program is running.

Front

True

Back

The term _______________ refers to all of the physical devices that a computer is made of.

Front

hardware

Back

The Python _______________ is a program that can read Python programming statements and execute them.

Front

interpreter

Back

True/False: Python allows programmers to break a statement into multiple lines.

Front

True

Back

True/False: The Python language uses a compiler, which is a program that both translates and executes the instructions in a high level language.

Front

False

Back

When applying the .3f formatting specifier to the following number, 76.15854, the result is _______________.

Front

76.159

Back

A(n) _____ structure is a logical design that controls the order in which a set of statements execute.

Front

control

Back

True/False: In Python, print statements written on separate lines do not necessarily output on separate lines.

Front

True

Back

Python uses _______________ to categorize values in memory.

Front

data types

Back

Which mathematical operator is used to raise five to the second power in Python?

Front

**

Back

A(n) _______________ character is a special character that is preceded with a backslash, appearing inside a string literal.

Front

escape

Back

True/False: Python formats all floating-point numbers to two decimal places when outputting using the print statement.

Front

False

Back

True/False: The CPU understands instructions written in a binary machine language.

Front

True

Back

A(n) _______________ is a set of instructions that a computer follows to perform a task.

Front

program

Back

True/False: The instruction set for a microprocessor is unique and is typically understood only by the microprocessors of the same brand.

Front

True

Back

The program development cycle is made up of _____ steps that are repeated until no errors can be found in the program.

Front

3

Back

The _____ function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program.

Front

input

Back

Boolean variable can reference one of two values: _____.

Front

true or false

Back

_______________ are small central processing unit chips.

Front

micro processors

Back

What type of error produces incorrect results but does not prevent the program from running?

Front

logic

Back

After the execution of the following statement, the variable sold will reference the numeric literal value as a(n) _____ data type: sold = 256.752

Front

float

Back

True/False: According to the behavior of integer division, when an integer is divided by an integer, the result will be a float.

Front

False

Back

True/False: The Python language is not sensitive to block structuring of code.

Front

False

Back

The output of the following print statement is: print 'I\'m ready to begin'

Front

I'm ready to begin

Back

After the execution of the following statement, the variable price will reference the value _____. price = int(68.549)

Front

68

Back

If value1 is 2.0 and value2 is 12, what is the output of the following command? print(value1 * value2)

Front

24.0

Back

A disk drive stores data by _______________ encoding it onto a circular disk.

Front

magnetically

Back

Which logical operators perform short-circuit evaluation?

Front

or, and

Back

The _______________ is the part of a computer that actually runs programs and is the most important component in a computer.

Front

cpu

Back

The _____ built-in function is used to read a number that has been typed on the keyboard.

Front

input()

Back

The _______________ specifier is a special set of characters that specify how a value should be formatted.

Front

formatting

Back

Main memory is commonly known as _______________.

Front

RAM

Back

What symbol is used to mark the beginning and end of a string?

Front

Quotation

Back

When using the _____ operator, one or both subexpressions must be true for the compound expression to be true.

Front

Or

Back

In a print statement, you can set the _____ argument to a space or empty string to stop the output from advancing to a new line.

Front

end

Back

True/False: The \t escape character causes the output to skip over to the next horizontal tab.

Front

True

Back

_______________ is a type of memory that can hold data for long periods of time, even when there is no power to the computer.

Front

secondary storage

Back

True/False: Python allows you to compare strings, but it is not case sensitive.

Front

False

Back

The decision structure that has two possible paths of execution is known as _____.

Front

double alternative

Back

Section 4

(50 cards)

Boolean variables are commonly used as _______________ to indicate whether a specific condition exists.

Front

flags

Back

The logical _______________ operator reverses the truth of a Boolean expression.

Front

not

Back


Front

moves whatever's after it to a new ling

Back

{}.format(something)

Front

Is the new string.format in Python 3. This is how indexing works: "My first name is {0} and my last name is {1}. You can call me {0}".format("John","Doe").

Back

my_list[0:]

Front

gives you the whole list, starting at the 0 position

Back

Python provides a special version of a decision structure known as the _______________ statement, which makes the logic of the nested decision structure simpler to write

Front

if elif else

Back

A(n) _______________ expression is made up of two or more Boolean expressions.

Front

compound

Back

list_name.append("")

Front

appends thing to lists

Back

%r

Front

String (converts any Python object using repr())

Back

%s

Front

Converts String (converts any Python object using str())

Back

for loops

Front

"for x in list_name" ... applies something to every item in a list

Back

True/False: The not operator is a unitary operator and it must be a compound expression.

Front

False

Back

data types

Front

i.e. numbers and booleans

Back

variables can be reassigned?

Front

True

Back

True/False: Decision structures are also known as selection structures.

Front

True

Back

exponents in python

Front

**

Back

In a decision structure, the action is _______________ executed because it is performed only when a certain condition is true.

Front

conditionally

Back

%r is used for...

Front

debugging and display

Back

index

Front

the number that each character in a string is assigned

Back

True/False: Nested decision structures are one way to test more than one condition.

Front

True

Back

boolean

Front

a data type that is like a light switch. it can only have two values: true, false

Back

What does % when printing string

Front

they allow the variables outside the string to enter into the string

Back

my_list[1:3]

Front

gives you the list starting at the 1st position and ending at the 2nd position

Back

integer vs. float

Front

integer is a number w/out a decimal; float is a number with a decimal

Back

len[2] = 3

Front

The 2nd term of the list is now equal to 3

Back

my_list.sort()

Front

sorts a list from lowest to highest, or alphabetical

Back

True/False: An action in a single alternative decision structure is performed only when the condition is true.

Front

True

Back

my_list[-1]

Front

gives you the last term in the list

Back

modulo

Front

%. Returns the remainder from a division.

Back

string methods

Front

let you perform specific tasks on strings

Back

my_list[:]

Front

gives you the entire list

Back

%s is used for

Front

display

Back

\

Front

tells Python not to end the string

Back

What's the difference between = and == in Python?

Front

= is the assignment operator. == is the equality operator.

Back

whitespace

Front

separates statements

Back

A(n) _______________ decision structure provides only one alternative path of execution.

Front

single alternative

Back

my_list.insert(4, "cat")

Front

Inserts the string "cat" at the 4th position in a list

Back

indentations in python

Front

mean that there is a code block

Back

A(n) _______________ statement will execute one block of statements if its condition is true, or another block if its condition is false.

Front

if/else

Back

exponent

Front

**

Back

True/False: Short-circuit evaluation is performed with the not operator.

Front

False

Back

%d

Front

Converts a signed integer decimal

Back

variable

Front

stores a piece of data and gives it a specific name

Back

string

Front

can contain letters, numbers, and symbols

Back

True/False: Expressions that are tested by the if statement are called Boolean expressions.

Front

True

Back

The _______________ statement is used to create a decision structure.

Front

If

Back

"""

Front

to display things as they're written in the .txt file

Back

A(n) _______________ operator determines whether a specific relationship exists between two values.

Front

relational

Back

len(my_list)

Front

finds the length of a list

Back

In flowcharting, the _______________ symbol is used to represent a Boolean expression.

Front

diamond

Back

Section 5

(50 cards)

x?

Front

matches an option x character (in other words, it matches an x wero or one times)

Back

Order of Conditionals

Front

1. not 2. and 3. or

Back

(x)

Front

in general is a remembered group. You can get the value of what matched by using the groups() method of the object returned by re.search

Back

adding parser options

Front

parser.add_option('-n, '--new')

Back

""" ............."""

Front

String for multiple lines of text; can be multi-line comment

Back

%d

Front

Integer format character

Back

==

Front

means equal to

Back

exists()

Front

Returns TRUE if file in argument exists, FALSE if not

Back


Front

line character; creates new line in string

Back

%r

Front

String format character; use for debugging

Back

(a|b|c|)

Front

matches either a or b or c

Back

write(stuff)

Front

Writes stuff to file

Back

\b

Front

matches a word boundar

Back

$

Front

matches the end of a string

Back

x+

Front

matches x one or more times

Back

x*

Front

matches x zero or more times

Back

Order of Precedence

Front

(*), (,/,%), (+,-)

Back

function

Front

1. Names code like variables name strings/numbers 2. Takes arguments the way scripts take argv 3. Using 1 and 2, allows for mini-commands

Back

<, <=, >, >=

Front

less than, less than or equal to, greater than, greater than or equal to

Back

!=

Front

means doesn't equal

Back

truncate()

Front

Empties the file

Back

close()

Front

- method flushes unwritten information and closes file object - Not necessary, but important best practice

Back

len(input)

Front

Return the number of items from a sequence or characters in a string

Back

read()

Front

- method reads a string from an open file - fileObject.read([count]) - Count = # of bytes to read, reads as much as possible if not given

Back

open()

Front

- function opens a file - Required argument is filename - Default access_mode is read(r) - Does not return actual content; creates/reads fileObject -

Back

round()

Front

function rounds floating point numbers round(1.773) = 2

Back

What's a dictionary?

Front

A list of tuples in curly brackets: {"x:y"}; x is a key, y is a value; dictionaries are unordered.

Back

not

Front

gives the opposite of the statement; i.e. "Not True is False"

Back

input()

Front

Assumes input is valid python expression, returns evaluated result

Back

or

Front

means one of the conditions must be true

Back

\t

Front

tab character

Back

%s

Front

String format character; use for user formatting

Back

github steps

Front

1. git status 2. git add (adds to staging) 3. git commit -m "What you've done" 4. git push -u origin master

Back

and

Front

means that both conditions must be true

Back

basic regex syntax

Front

match = re.search(pattern, text)

Back

modules

Front

-aka libraries -feature sets you can import into a program

Back

^

Front

matches the beginning of a string

Back

raw_input('prompt:')

Front

Reads a line of input from user and returns as string

Back

\d

Front

matches any numeric digit

Back

optparse first command

Front

import optparse parser = optparse.OptionParser

Back

argv

Front

- argument variable - variable holds arguments passed to script when running it script, first, second, third = argv (line 3) - script = name of python script - first, second, third = 3 variables arguments assigned to

Back

How many characters to a line?

Front

80 characters

Back

\D

Front

matches any non-numeric character

Back

\

Front

escape; tells python to ignore following character, or puts difficult characters into strings when used with specific escape sequences

Back

readline()

Front

Reads one line of text file

Back

Control flow statements

Front

if, for, while

Back

x{n,m}

Front

matches an x character at least n times, but not more than m times

Back

What is sys.argv?

Front

It allows you to input parameters from the command line.

Back

after we've added options (in parser)

Front

(options, args) = parser.parse_args()

Back

raw_input()

Front

Raw input prompts the user for an input and then turns that input into a string. In between "(" and ")" the programmer writes the prompt that will prompt the user. When you set raw_input() equal to a variable, that variable becomes what the user inputs.

Back

Section 6

(50 cards)

Boolean tests should be..

Front

...simple. If complex, move calculations to variables earlier in function and use a good name for the variable.

Back

!=

Front

not equal

Back

pop()

Front

method removes and returns the last object from a list

Back

as

Front

if we want to give a module a different alias

Back

del

Front

deletes objects

Back

else

Front

optional. Used after elif to catch other cases not provided for.

Back

def

Front

used to create a new user defined function

Back

floating point numbers

Front

-Scientific notation in computers -Allows very large and small numbers using exponents -Made up of: Significand: 5, 1.5, -2.001 Exponent: 2, -2 -Put decimal after integers to make floating point 1 ~ 1.0

Back

elif

Front

stands for else if. if the first test evaluates to False, continues with the next one

Back

return

Front

exits the function and returns a value

Back

raise

Front

create a user defined exception

Back

if

Front

Used to determine, which statements are going to be executed

Back

try

Front

specifies exception handlers

Back

Cardinal Numbers

Front

Start at 0

Back

print

Front

print to console

Back

sorted()

Front

Sorts a list from smallest to highest or a string alphabetically sorted(str, reverse=True) <- Sorts backwards

Back

not

Front

negates a boolean value

Back

\\

Front

backslash (\)

Back

finally

Front

is always executed in the end. Used to clean up resources.

Back

A while-loop is...

Front

an infinite loop. "while True" ~ "While true is true, run this:"

Back

exec

Front

executes Python code dynamically

Back

lambda

Front

creates a new anonymous function

Back

Ordinal Numbers

Front

Start at 1; First, second, third

Back

for

Front

iterate over items of a collection in order they appear

Back

Treat if statements like...

Front

..paragraphs. Each if, elif, and else grouping is like a set of sentences. Put blank lines before and after.

Back

Every if statement must have a(n)...

Front

else

Back

break

Front

interrupt the (loop) cycle

Back

5 % 3

Front

Modulo; remainder of the division 5 % 3 = 2 (3 goes into 5 once, remainder 2)

Back

is

Front

tests for object identity

Back

**

Front

exponent

Back

assert

Front

used for debugging purposes

Back

from

Front

for importing a specific variable, class or a function from a module

Back

yield

Front

is used with generators

Back

close()

Front

- method flushes unwritten information and closes file object - Not necessary, but important best practice

Back

continue

Front

used to interrupt the current cycle, without jumping out of the whole cycle. New cycle will begin.

Back

Never nest if-statements more than..

Front

..two deep. Try to do one deep (put inside another function).

Back

global

Front

access variables defined outside functions

Back

Else must have a...

Front

die function that prints out an error message, in case the else doesn't make sense. Shows errors.

Back

def

Front

Defines a function def function1(): print "this is function 1"

Back

append()

Front

Adds input to the end of a list

Back

int()

Front

Convert a string to an integer int(raw_input(> ))

Back

class

Front

-way of producing objects with similar attributes and methods. -used to create new user defined objects -an object is an instance of a class

Back

lower()

Front

converts a string to lowercase

Back

except

Front

catches the exception and executes codes

Back

while

Front

controls flow of the program with truth statements. Statements inside the while loop are executed until the expression evaluates false.

Back

pass

Front

does nothing

Back

x += y

Front

ADD AND x = x + y

Back

upper()

Front

converts a string to uppercase

Back

A for-loop is...

Front

Back

split()

Front

Method splits a string into separate phrases - Default is to split on whitespace split(str, num) str = separator (optional) numb = number of separations (optional)

Back

Section 7

(50 cards)

Syntax to index 2 nested lists?

Front

list[x][y]

Back

**=

Front

Exponent AND. Performs exponential calculation on operators and assigns value to left operand. A*=B ~ A = A*B

Back

\b

Front

ASCII Backspace (BS) - Erases last character printed

Back

keys()

Front

Returns an array of dict's keys

Back

%e

Front

Floating point exponential format (lowercase)

Back

%u

Front

unsigned decimal

Back

get()

Front

Returns a value for the given key. If key is not available, returns default of 'none'.

Back

%d

Front

signed integer decimal

Back

items()

Front

Returns a list of a dict's tuple pairs (key, value)

Back

%=

Front

Modulus AND. Takes modulus using two operands and assigns the result to left operand A%=B ~ A = A%B

Back

%X

Front

Unsigned Hexadecimal (uppercase)

Back

%c

Front

Single character -accepts integer or single char string

Back

-=

Front

Subtract AND. Subtracts right operand from left and assigns the result to the left. A-=B ~ A = A - b

Back

%s

Front

String -Converts any python object using str()

Back

+=

Front

Add AND. Adds right operand to the left and assigns the result to the left. A += B ~ A = A + B

Back

function parameter

Front

Variable name for passed in argment def function(parameter):

Back

tuple

Front

An immutable sequence of Python objects -Immutable; can't be changed -Similar to list, but can't be modified - Uses (), ends in ; tuple1 = ('word', 1, False);

Back

"mutable"

Front

can be changed after created

Back

%G

Front

Same as "E" if exponent is greater than -4 or less than precision

Back

%r

Front

String -converts any python object using repr()

Back

enumerate()

Front

gives an index number to each element in a list

Back

\f

Front

ASCII FormFeed (FF) - ASCII Control character. Forces printer to eject current page and continue printing at top of another.

Back

\r

Front

ASCII Carriage Return (CR) - Resets position to beginning of a line of text

Back

%g

Front

Same as "e" if exponent is greater than -4 or less than precision

Back

\"

Front

Double-quote (")

Back

%x

Front

Unsigned hexadecimal (lowercase)

Back

*=

Front

Multiply AND. Multiplies left operand by right and assigns product to left operand A=B ~ A = AB

Back

// (operator)

Front

Floor Division. Numbers after the decimal in the quotient are removed - 9//2 = 4

Back

del keyword

Front

deletes key/value pairs from dict

Back


Front

ASCII LineFeed (LF) - Goes to next line -newline escape

Back

dictionary

Front

A list whose objects can be accessed with a key instead of an index. Key can be any string or number. d = {'key1' : 1, 'key2' : 2}

Back

%E

Front

Floating point exponential format (uppercase)

Back

items()

Front

Returns an array of dict key/value pairs

Back

<>

Front

Value of two operands not equal? -Similar to !=

Back

.remove()

Front

removes items from list

Back

\v

Front

ASCII Vertical Tab (VT) - 6 vertical lines; 1 inch

Back

%o

Front

unsigned octal

Back

values()

Front

Returns an array of dict's values

Back

%i

Front

signed integer decimal

Back

sort()

Front

sorts a list from smallest to greatest

Back

function argument

Front

passed in for function parameter function(argument)

Back

universal import

Front

Imports all functions and variables from a module - Can cause conflicts with user defined functions and vars - Better to import only necessary functions from module import *

Back

%

Front

no argument converted, results in "%" in the result

Back

%F

Front

Floating point decimal format (UPPERCASE)

Back

\t

Front

ASCII Horizontal Tab (TAB) - 8 horizontal spaces; tab

Back

zip()

Front

Combines two or 3 lists to return all values in for loops

Back

\'

Front

Single Quote (')

Back

range()

Front

Returns a list of numbers from start up to (but not including) stop start defaults to 0 and step defaults to 1 range(stop) range(start, stop) range(start, stop, step)

Back

\a

Front

ASCII Bell -may cause receiving device to emit a bell or warning of some kind

Back

%f

Front

Floating point decimal format (lowercase)

Back

Section 8

(50 cards)

argv

Front

the "argument variable," a very standard name in programming, that you will find used in many other languages. This variable holds the arguments you pass to your Python script when you run it. You know how you type python ex13.py to run the ex13.py file? Well the ex13.py part of the command is called an "argument." What we'll do now is write a script that also accepts arguments. What's the difference between argv and raw_input()? The difference has to do with where the user is required to give input. If they give your script inputs on the command line, then you use argv. If you want them to input using the keyboard while the script is running, then use raw_input(). Line 3: script, first, second, third = argv Line 3 "unpacks" argv so that, rather than holding all the arguments, it gets assigned to four variables you can work with: script, first, second, and third. This may look strange, but "unpack" is probably the best word to describe what it does. It just says, "Take whatever is in argv, unpack it, and assign it to all of these variables on the left in order." (ex13.py)

Back

from sys import argv

Front

Called an "import." This is how you add features to your script from the Python feature set. Rather than give you all the features at once, Python asks you to say what you plan to use. This keeps your programs small, but it also acts as documentation for other programmers who read your code later. May access features other than "argv"

Back

#

Front

Octothorpe use for comments on the code, use to disable code placing a # at the beginning of a line or in the middle of a line tells python to ignore whatever is written on the line after the #

Back

bit mask

Front

variable used to determine if bits are on or off in an input -sort of works like a multiple choice test key -can be used with | to turn bits on if off -use with ^ and 11111111 to flip all bits def check_bit4(input): mask = 0b1000 desired = input & mask if desired > 0: return "on" return "off"

Back

import

Front

This is how you add features to your script from the Python feature set. Rather than give you all the features at once, Python asks you to say what you plan to use. This keeps your programs small, but it also acts as documentation for other programmers who read your code later.

Back

5 << 1

Front

bitwise left shift -shifts turned on bits to the left 0b001 << 1 = 0b010

Back

\ooo

Front

Character with octal value ooo

Back

strings

Front

A string is usually a bit of text you want to display to someone, or "export" out of the program you are writing. Python knows you want something to be a string when you put either " (double-quotes) or ' (single-quotes) around the text. You saw this many times with your use of print when you put the text you want to go inside the string inside " or ' after the print to print the string. Strings may contain the format characters you have discovered so far. You simply put the formatted variables in the string, and then a % (percent) character, followed by the variable. The only catch is that if you want multiple formats in your string to print multiple variables, you need to put them inside ( ) (parenthesis) separated by , (commas). It's as if you were telling me to buy you a list of items from the store and you said, "I want milk, eggs, bread, and soup." Only as a programmer we say, "(milk, eggs, bread, soup)."

Back

from .... import ....

Front

imports specific attributes from a module

Back

%x

Front

Signed hexidecimal

Back

"""

Front

Use to make a string that needs multiple lines for the string text.

Back

"

Front

Every time you put " (double-quotes) around a piece of text you have been making a string. A string is how you make something that your program might give to a human. You print strings, save strings to files, send strings to web servers, and many other things. ' (single-quotes) also work for this purpose.

Back

5 >> 4

Front

bitwise right shift -shifts turned on bits to the right 0b010 >> 1 = 0b001

Back

True False

Front

Python recognizes True and False as keywords representing the concept of true and false. If you put quotes around them then they are turned into strings and won't work.

Back

module

Front

a file containing Python definitions, statements or scripts, can be user defined or from a built-in library

Back

global variable

Front

available everywhere

Back

PEMDAS

Front

Order of Operations: Mode of Operations: Parentheses Exponents Multiplication Division Addition Subtraction

Back

Floating Point Number

Front

any number with a decimal point showing one or more digits behind the decimal point. e. "4.0" or "0.087"

Back

filter()

Front

-filters a list for terms that make the function true filter(function, list) filter(lambda x: x%3 ==0, my_list) -for anonymous (throwaway) functions

Back

%f

Front

float Floating point decimal format

Back

How do I get a number from someone so I can do math?

Front

That's a little advanced, but try x = int(raw_input()) which gets the number as a string from raw_input() then converts it to an integer using int()

Back

%

Front

Modulus is NOT used as a "percentage" sign in the programming language

Back

method

Front

function of an object

Back

variables

Front

can only start with a character (not a number)

Back

member variables

Front

variables only available to members of certain class

Back

12 ^ 42

Front

Bitwise XOR, EXCLUSIVE OR Turns bits on if EITHER but not BOTH bits of inputs are turned on 0b1010 ^ 0b1101 = 0b0111

Back

''',"""

Front

Free-form strings

Back

seek()

Front

move to a new position in file, reads bytes

Back

,

Front

We put a , (comma) at the end of each print line. This is so print doesn't end the line with a newline character and go to the next line

Back

instance variable

Front

variable only available to one instance of a class

Back

%c

Front

Single character

Back

%o

Front

Signed octal value

Back

=

Front

assigns values from right side operands to left side operand

Back

\uxxxx

Front

Character with 16-bit hex value xxxx (Unicode only)

Back

sys

Front

module - contains important objects and functions

Back

os

Front

module - OS routines for NT or POSIX

Back

8 & 5

Front

bitwise AND Turns on bits turned on in BOTH inputs 0b100 & 0b101 = 0b100

Back

Variable

Front

A letter or word for a value that can vary or change

Back

.read()

Front

reads the specified file use by entering at the end of the variable used to specify the file you have 'opened'.

Back

Write comments on code ...

Front

No, you write comments only to explain difficult to understand code or why you did something. Why is usually much more important, and then you try to write the code so that it explains how something is being done on its own. However, sometimes you have to write such nasty code to solve a problem that it does need a comment on every line. In this case it's strictly for you to practice translating code to English.

Back

variable

Front

a name for a place to store strings, numbers etc.

Back

%d, %i

Front

Signed integer decimal

Back

list slicing

Front

Way to access elements list[start:end:stride] -stride = count by __'s -any term can be omitted, will be set to default - a negative stride progresses through list backwards

Back

~88

Front

Bitwise NOT flips all bits in a number for integers, effectively adds 1 and makes negative

Back

%d

Front

digit

Back

\xhh

Front

Character with hex value hh

Back

%e

Front

Floating point exponential format

Back

9 | 4

Front

Bitwise OR Turns on bits if turned on in either input 0b001 | 0b100 = 0b101

Back

\Uxxxxxxxx

Front

Character with 32-bit hex value xxxxxxxx (Unicode only)

Back

list comprehension

Front

Python rules for creating lists intelligently s = [x for x in range(1:51) if x%2 == 0] [2, 4, 6, 8, 10, 12, 14, 16, etc]

Back

Section 9

(50 cards)

function import

Front

import a function from a module (from module import function)

Back

grep

Front

find things inside files

Back

generic import

Front

ex: import math (import module)

Back

echo

Front

pint some arguments

Back

List/Array

Front

A list of possible values for a variable. In the fortune teller there was an array of jobs.

Back

.isalpha()

Front

is a letter

Back

raw_Input

Front

accepts a string, prints it, and then waits for the user to type something and press Enter (or Return).

Back

Comparators

Front

< > <= >= == !=

Back

popd

Front

pop directory

Back

Iteration

Front

A Repeat or Loop. This is where the code uses "while" or "for" loops

Back

FOR Loop

Front

To repeat a commands a set number of times.

Back

Function

Front

Some code that has been grouped together so that it can be reused by "calling" the function name. Like a mini-program within a program.

Back

ls

Front

list directory

Back

concatenation

Front

combine

Back

mv

Front

move a file or directory

Back

find

Front

find files

Back

Logic error

Front

An error that means the code will run, but will not do what is expected.

Back

.upper

Front

makes uppercase

Back

IF Statement

Front

To test if a condition is true (e.g. if age >17)

Back

cp

Front

copy a file or directory

Back

apropos

Front

find what man page is appropriate

Back

universal import

Front

access to all variables and functions in an import without having to type math.function constantly. (from module import *) con: fill your program with a ton of variables and functions and may not link them correctly to the module (your functions and their functions may get confused)

Back

Syntax error

Front

An error in the code that means it will not run. Incorrect spelling of keywords, leaving off speech marks or brackets, not using colons for "if" statements.

Back

export

Front

export/set a new environment variable

Back

sudo

Front

DANGER! become super use root! DANGER!

Back

Selection

Front

A choice or decision. This is where the code uses "If", "else" or "elif" to decide what to do.

Back

xargs

Front

execute arguments

Back

WHILE Loop

Front

To repeat while a condition is true (e.g. while score < 100)

Back

.lower

Front

makes lowercase

Back

Conditional Statement: if

Front

if is a conditional statement that executes some specified code after checking if its expression is True.

Back

Integer

Front

A whole number

Back

exit

Front

exit the shell

Back

Boolean Operators

Front

Order: Not, And, Or

Back

use imported function from module

Front

ex: math.sqrt() (module.function)

Back

mkdir

Front

make directory

Back

Conditional Statement: Elif

Front

short for else if...otherwise, if the following expression is true, do this!

Back

cat

Front

print the whole file

Back

hostname

Front

my computer's network name

Back

rmdir

Front

remove directory

Back

less

Front

page through a file

Back

Floating Point

Front

A decimal

Back

Conditional Statement: Else

Front

executes some specified code after finding that the original expression was False (or opposite of the if command)

Back

Functions

Front

1) HEADER def function and add parameters 2) add additional """COMMENT here""" that explains the function 3)BODY describes procedures the function carries out, is indented

Back

env

Front

look at your environment

Back

String

Front

A text value such as a word or name

Back

cd

Front

change directory

Back

Data type

Front

The type of data being used. Could be any of those below

Back

man

Front

read a manual page

Back

pushd

Front

push directory

Back

pwd

Front

print working dictionary

Back

Section 10

(50 cards)

strings

Front

list of characters

Back

What is the structure that causes a statement or a set of statements to execute repeatedly?

Front

Repetition

Back

module

Front

A file containing definitions and statements intended to be imported by other programs.

Back

min()

Front

takes smallest out of a set of numbers and returns it

Back

[:2]

Front

# Grabs the first two items

Back

algorithm

Front

A set of specific steps for solving a category of problems

Back

d = {'key1' : 1, 'key2' : 2, 'key3' : 3}

Front

dictionary **not curly braces

Back

syntax error

Front

An error in a program that makes it impossible to parse — and therefore impossible to interpret.

Back

syntax

Front

The structure of a program

Back

What type of loop structure repeats the code a specific number of times

Front

Count-controlled loop

Back

In Python, the variable in the for clause is referred to as the _____ because it is the target of an assignment at the beginning of each loop iteration.

Front

Target Variable

Back

integer division

Front

An operation that divides one integer by another and yields an integer. Integer division yields only the whole number of times that the numerator is divisible by the denominator and discards any remainder.

Back

Which of the following represents an example to calculate the sum of the numbers (accumulator)?

Front

total += number

Back

In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called a _____.

Front

list

Back

how to loop through dictionaries keys

Front

d = {"foo" : "bar"} for key in d: print d[key]

Back

element

Front

One of the values in a list (or other sequence). The bracket operator selects elements of a list.

Back

argument

Front

a value provided to a function when the function is called. This value is assigned to the corresponding parameter in the function.

Back

A(n) ??-controlled loop causes a statement or set of statements to repeat as long as a condition is true.

Front

Condition

Back

The variable used to keep the running total

Front

Accumulator

Back

What type of loop structure repeats the code based on the value of the Boolean expression

Front

Condition-controlled loop

Back

A(n) ?? structure causes a statement or set of statements to execute repeatedly.

Front

Repetition

Back

access dictionary values

Front

list[item]

Back

comment

Front

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

Back

type()

Front

returns what "type" of data ex: int, float, str

Back

print

Front

A function used in a program or script that causes the Python interpreter to display a value on its output device.

Back

True/False: A better way to repeatedly perform an operation is to write the statements for the task once, and then place the statements in a loop that will repeat the statements as many times as necessary.

Front

True

Back

for loop

Front

applies function to every item in list for x in a: print x can sort functions for number in my_list print number #prints out every number on its own line

Back

abs()

Front

gives absolute value of that number (distance from zero)

Back

True/False: The first line in the while loop is referred to as the condition clause.

Front

True

Back

When will the following loop terminate? while keep_on_going != 999 :

Front

When keep_on_going refers to a value not equal to 999

Back

semantic

Front

the meaning of a program

Back

What is the format for the while clause in Python

Front

while condition : statement

Back

True/False: In Python, an infinite loop usually occurs when the computer accesses the wrong memory address.

Front

False

Back

str

Front

converts to a string

Back

True/False: In flowcharting, the decision structure and the repetition structure both use the diamond symbol to represent the condition that is tested.

Front

True

Back

list.append()

Front

add to a list by typing list_name.append()

Back

max()

Front

takes largest out of a set of numbers and returns it

Back

high-level language

Front

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

Back

_____ is the process of inspecting data that has been input to a program to make sure it is valid before it is used in a computation.

Front

Input validation

Back

assignment statement

Front

replaces item in list list_name[index number] = "reassignment"

Back

.insert(index, item)

Front

insert a certain item into a list at a certain index

Back

my_list[3:]

Front

# Grabs the fourth through last items

Back

.index(item)

Front

Find the index of an item

Back

slicing lists

Front

letters = ['a', 'b', 'c', 'd', 'e'] slice = letters[1:3] print slice print letters **when slicing if you wanted numbers 1 and 2 you would slice [0:2] so the code would include both the index 0 and 1

Back

key

Front

similar to index but uses a string or number

Back

mutable

Front

can be changed after created

Back

semantic error

Front

An error in a program that makes it do something other than what the programmer intended.

Back

runtime error

Front

An error that does not occur until the program has started to execute but that prevents the program from continuing.

Back

In Python, you would use the ?? statement to write a count-controlled loop.

Front

For

Back

dictionary

Front

similar to a list but you access values by looking at a key rather than an index useful for information using strings and values i.e. phonebook, email databases (passwords, and usernames)

Back

Section 11

(50 cards)

The term _______________ refers to all of the physical devices that a computer is made of.

Front

hardware

Back

True/False: RAM is a volatile memory used for temporary storage while a program is running.

Front

True

Back

True/False: An action in a single alternative decision structure is performed only when the condition is true.

Front

True

Back

The Python _______________ is a program that can read Python programming statements and execute them.

Front

interpreter

Back

A(n) _____ structure is a logical design that controls the order in which a set of statements execute.

Front

control

Back

Python provides a special version of a decision structure known as the _______________ statement, which makes the logic of the nested decision structure simpler to write

Front

if elif else

Back

True/False: Python formats all floating-point numbers to two decimal places when outputting using the print statement.

Front

False

Back

True/False: The CPU understands instructions written in a binary machine language.

Front

True

Back

The program development cycle is made up of _____ steps that are repeated until no errors can be found in the program.

Front

3

Back

The _____ built-in function is used to read a number that has been typed on the keyboard.

Front

input()

Back

Programs are commonly referred to as

Front

software

Back

A(n) ?? validation loop is sometimes called an error trap or an error handler.

Front

Input

Back

After the execution of the following statement, the variable price will reference the value _____. price = int(68.549)

Front

68

Back

In _______________ mode, the interpreter reads the contents of a file that contains Python statements and executes each statement.

Front

script

Back

In a decision structure, the action is _______________ executed because it is performed only when a certain condition is true.

Front

conditionally

Back

Main memory is commonly known as _______________.

Front

RAM

Back

The _______________ statement is used to create a decision structure.

Front

If

Back

A(n) _______________ statement will execute one block of statements if its condition is true, or another block if its condition is false.

Front

if/else

Back

True/False: Nested decision structures are one way to test more than one condition.

Front

True

Back

In flowcharting, the _______________ symbol is used to represent a Boolean expression.

Front

diamond

Back

True/False: Expressions that are tested by the if statement are called Boolean expressions.

Front

True

Back

%

Front

Percent: used for modulus. The modulus operation finds the remainder after division of one number after another. Example: 75 % 4 = 3, because 4 * 18 is 72, with 3 remaining

Back

What type of error produces incorrect results but does not prevent the program from running?

Front

logic

Back

<=

Front

Less than or equal to

Back

True/False: The \t escape character causes the output to skip over to the next horizontal tab.

Front

True

Back

The line continuation character is a _____.

Front

\

Back

What type of volatile memory is usually used only for temporary storage while running a program?

Front

RAM

Back

Boolean variable can reference one of two values: _____.

Front

true or false

Back

The ?? function is a built-in function that generates a list of integer values.

Front

Range

Back

Python uses _______________ to categorize values in memory.

Front

data types

Back

The _______________ specifier is a special set of characters that specify how a value should be formatted.

Front

formatting

Back

Which of the following is considered to be the world's first programmable electronic computer

Front

ENIAC

Back

True/False: In Python, print statements written on separate lines do not necessarily output on separate lines.

Front

True

Back

True/False: The Python language is not sensitive to block structuring of code.

Front

False

Back

A(n) _______________ is a name that represents a value stored in the computer's memory.

Front

variable

Back

*

Front

Asterisk: used for miltiplication

Back

/

Front

Slash: used for division

Back

True/False: Python allows programmers to break a statement into multiple lines.

Front

True

Back

Where does a computer store a program and the data that the program is working with while the program is running?

Front

Main memory

Back

When using the _____ operator, one or both subexpressions must be true for the compound expression to be true.

Front

Or

Back

A(n) _______________ expression is made up of two or more Boolean expressions.

Front

compound

Back

What is the informal language that programmers use to create models of programs that have no syntax rules and are not meant to be compiled or executed?

Front

pseudocode

Back

_______________ are notes of explanation that document lines or sections of a program.

Front

comments

Back

True/False: Python allows you to compare strings, but it is not case sensitive.

Front

False

Back

True/False: Computer programs typically perform three steps: Input is received, some process is performed on the input, and output is produced.

Front

True

Back

The _____ function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program.

Front

input

Back

The _______________ is the part of a computer that actually runs programs and is the most important component in a computer.

Front

cpu

Back

After the execution of the following statement, the variable sold will reference the numeric literal value as a(n) _____ data type: sold = 256.752

Front

float

Back

A(n) _______________ is a set of instructions that a computer follows to perform a task.

Front

program

Back

In a print statement, you can set the _____ argument to a space or empty string to stop the output from advancing to a new line.

Front

end

Back

Section 12

(15 cards)

os.path

Front

Operating system path module: allows many functions to occur on a specified path. Ex: os.path exists will return a true or false if a file does or doesn't exist

Back

Modules

Front

Python's built-in features are called modules. Also called "libraries" by some programmers. Example speech: "you want to use the sys module."

Back

read

Front

A method/function/command to read the file

Back

close

Front

A method/function/command to close the file

Back

raw_input

Front

Pauses the script at the point it shows up, gets the answer from the keyboard, then continues the script. It is one of python's built-in functions Looks something like: var = raw_input("Enter_Something") Where "Enter_Something" is what the prompt is, asking you to enter some text, and var is where the text is stored Remember the %r in the prompt

Back

script

Front

Will input the name of the script into your code when called

Back

string

Front

A string is a list of characters inside of quotes. Strings can be made of single, double or triple quotes.

Back

PEDMAS

Front

Order of operations: parentheses, exponents, multiplication, division, addition, subtraction

Back

Formatter

Front

Placeholders that "punch out a hole in the code % is the character for this

Back

>=

Front

Greater than or equal

Back

variable

Front

A variable is something that holds a value that may change. In simplest terms, a variable is just a box that you can put stuff in. You can use variables such as numbers. Ex: lucky = 7 print(lucky) 7

Back

truncate

Front

A method/function/command to empty the file. Be careful if you care about the file

Back

readline

Front

A method/function/command to read just one line of a text file

Back

open(argument, 'w')

Front

Open a file with an extra parameter. Python has several open parameters that open a file different ways

Back

prompt

Front

A formatter text that is used to give the user the ability to type in a question

Back