Exam 1 Flashcards

1
Q

What is a “program”

A

An algorithm to accomplish a task

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

What is an “IDE”

A

Integrated Development Environment:
A compiler like spyder

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

Quality assurance

A

how someting is checked to make sure it works as it is supposed to

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

what is a unit test?

A

Software test that focuses on components of a program

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

What is a test suite and a test runner

A

collection of test cases to run a single job with different test scenarios
Test runner: tool that is used to run tests and export results

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

t or f:

A

false, it should contain only one assertion statement

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

what is TDD

A

test driven development:
development where software requirements are converted tot est cases before software is fully developed

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

what is pseudocode, why helpful

A

pseudocode is informal way of programming that does not require strict language syntax
can be helpful cuz more understandable

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

What is a module, why helpful

A

a file that defines a collection of useful functions and variables, usually have a common theme or purpose
helpful so no need to redefine functions or variables every time

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

what is a statement in a program

A

a command in a program that a computer understands

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

what is an expression

A

value or anything that executes and becomes a value

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

what are the rules for a valid variable name

A

1) start with a letter or underscore
2) only made of letters numbers or underscores
3) capitalized letters matter

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

is a==A

A

no

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

why is x = x**2 always valid

A

the expression updates x

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

what is an operand

A

term used to describe the data or values that are operated on by an operater

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

name three types and describe each of them

A

1) numeric (int, float, complex)
2) text sequence (string) words
3) sequence: list and range
4) binary sequence
5) plot: graphical representation of numeric data
etc…….

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

binary operator?

A

operators that require two operands at least eg +, -, *

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

unary operator?

A

operators that require one operand
only needs one operand: negative or positive

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

what does = do?

A

assigns a value to a variable

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

what does == do

A

compares two values to determine if they’re equal

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

what does % do

A

output is the remainder

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

waht does // do

A

divides and returns only integer result
eg -8//3 is -3 because answer is -2.67777… so rounds up

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

what will -8/3 calculate to

A

-3

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

what will 8%-3 calculate to

A

will be -3 because because will return a value that is the same sign as the denominator
goes in opp direction
3 * 3 = 9 so remainder is -1
3*2 = 6 so remainder is +2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
relational operator?
operator that compares two values and returns true or false
26
what is the order of precedence in decreasing of the and, not, or
1) not 2) and 3) or
27
do arithmetic or relational operators have higher precedence
arithmetic
28
t or f: all realtional operations have the same precedence
true
29
what are lists
array... usually composed of same variables
30
how do you express the third elemnt in a list
list[2]
31
how would you express second to last element in a list
if list is n long, list[n-2] or list[-2]
32
given a list x = [1, 2, 3,4 ,5], what will x[2::2] return
will return [3, 5] starts from x[2] and has step of 2
33
what does import do
import is used to give access to different python moduels
34
what does len() do
gives the elngth of an object, number of items in a list
35
what does .append() do
adds whatever is inside () to the end of existing array
36
what makes up np.linspace() command
np.linspace(start, stop, how many samples to generate).astype(int or float) int: determines whether elements are floats or integers
37
what are three attrinbutes of a numpy array
1. always homogenous (same data type) 2. optimized for numerical and scientific computation 3. can be manipulated using mathematical functions like linear algebra etc 4. consumes less memory
38
deep copy vs shallow copy?
shallow: constructs new compound object and inserts references into the array deep: recursively inserts copies of the og into each entry
39
Why indent?
indicates a block of code
40
how many spaces in a single indent?
4 spaces
41
What is the difference between a parameter and an argument?
A parameter is a placeholder for a certain type of value while an argument defines the parameter's value
42
If a function does not need to return anything, what does the return expression look like
no return statement
43
List convention for docstring
1) first line should be short concise function summary 2) The first line should be a phrase ending in a period 3)Indent lines consistently 4) Separate lines with a blank line when needed
44
what is PEP
document where new features in python can be proposed
45
Abs Error vs Rel Error?
Abs error is the difference between measured eerror and true error Rel error is the absoute error divided by true value (percentage)
46
What is the hidden bit?
gives the sign of the number
47
what is machine epsilon?
The difference between 1.0 and the next larger representable number
48
in double precision IEEE-754 , how many binary bits are used to store a real number
64 bits 1 bit for sign, 11 bits for exponent, and 52 bits for significant
49
What information does the sign bit give
gives the sign of the number
50
what information does the exponent give
Scaling factor, determines how many decimal places
51
What informaiton does the significand give?
fractional values, amt of sig figs
52
What does assert do?
Used to test a condition assert condition, message if condition is not true, message is raised with assertion error
53
what is assert best used for?
good for debugging and teesting assumptions bad for data validation
54
what does [0:2] do
in a list it would slice out all entries past 1. This is because start is inclusive while stop is excusive
55
Metaphor for and
switches in series
56
Metaphor for or
switches in parallel
57
The inverse of an upper triangular matrix is also an__
upper triangular matrix
58
What is (AB)^-1 equal to
B^-1 * A^-1
59
T or f: an LU decomp always exists if the matrix is square invertible without altering the matrix
False
60
if Q is an invertible square matrixwhat is Q.T * Q equivalent to
I