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
Q

relational operator?

A

operator that compares two values and returns true or false

26
Q

what is the order of precedence in decreasing of the and, not, or

A

1) not
2) and
3) or

27
Q

do arithmetic or relational operators have higher precedence

A

arithmetic

28
Q

t or f: all realtional operations have the same precedence

A

true

29
Q

what are lists

A

array… usually composed of same variables

30
Q

how do you express the third elemnt in a list

A

list[2]

31
Q

how would you express second to last element in a list

A

if list is n long,
list[n-2]
or list[-2]

32
Q

given a list x = [1, 2, 3,4 ,5], what will x[2::2] return

A

will return [3, 5]
starts from x[2] and has step of 2

33
Q

what does import do

A

import is used to give access to different python moduels

34
Q

what does len() do

A

gives the elngth of an object, number of items in a list

35
Q

what does .append() do

A

adds whatever is inside () to the end of existing array

36
Q

what makes up np.linspace() command

A

np.linspace(start, stop, how many samples to generate).astype(int or float)
int: determines whether elements are floats or integers

37
Q

what are three attrinbutes of a numpy array

A
  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
Q

deep copy vs shallow copy?

A

shallow: constructs new compound object and inserts references into the array
deep: recursively inserts copies of the og into each entry

39
Q

Why indent?

A

indicates a block of code

40
Q

how many spaces in a single indent?

A

4 spaces

41
Q

What is the difference between a parameter and an argument?

A

A parameter is a placeholder for a certain type of value while an argument defines the parameter’s value

42
Q

If a function does not need to return anything, what does the return expression look like

A

no return statement

43
Q

List convention for docstring

A

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
Q

what is PEP

A

document where new features in python can be proposed

45
Q

Abs Error vs Rel Error?

A

Abs error is the difference between measured eerror and true error
Rel error is the absoute error divided by true value (percentage)

46
Q

What is the hidden bit?

A

gives the sign of the number

47
Q

what is machine epsilon?

A

The difference between 1.0 and the next larger representable number

48
Q

in double precision IEEE-754 , how many binary bits are used to store a real number

A

64 bits
1 bit for sign, 11 bits for exponent, and 52 bits for significant

49
Q

What information does the sign bit give

A

gives the sign of the number

50
Q

what information does the exponent give

A

Scaling factor, determines how many decimal places

51
Q

What informaiton does the significand give?

A

fractional values, amt of sig figs

52
Q

What does assert do?

A

Used to test a condition
assert condition, message
if condition is not true, message is raised with assertion error

53
Q

what is assert best used for?

A

good for debugging and teesting assumptions

bad for data validation

54
Q

what does [0:2] do

A

in a list it would slice out all entries past 1.
This is because start is inclusive while stop is excusive

55
Q

Metaphor for and

A

switches in series

56
Q

Metaphor for or

A

switches in parallel

57
Q

The inverse of an upper triangular matrix is also an__

A

upper triangular matrix

58
Q

What is (AB)^-1 equal to

A

B^-1 * A^-1

59
Q

T or f: an LU decomp always exists if the matrix is square invertible without altering the matrix

A

False

60
Q

if Q is an invertible square matrixwhat is Q.T * Q equivalent to

A

I