Exam 1 Flashcards

1
Q

variables

A

named storage bins that hold onto values

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

assignment statements

A

a line of code that assigns a value to a variable

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

float

A

numbers with decimals
float()

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

integers

A

numbers without decimals
int()

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

string

A

text
str()

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

comments

A

used to explain code
#

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

variable naming conventions

A
  • cannot start with numbers
  • no numbers after _
  • all lowercase
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

expression

A

any mathematic calculation found on the right side of a statement

ex: x + 3

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

//

A

integer division

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

%

A

remainder division

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

input()

A

accepts a value from the user (always stored as a string)

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

opening a file

A

with open(“file_name”, “r”) as infile:

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

reading a file line

A

infile.readline()

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

skipping a file line

A

next(infile)

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

plotting import statement

A

import matplotlib.pyplot as plt

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

main plotting functions (5)

A

Plt.plot(x, y, marker)
Plt.title(title)
Plt.xlabel(xlabel)
Plt.ylabel(ylabel)
Plt.show( )

17
Q

boolean

A

a data type that can only store 2 values (True or False)

18
Q

comparison operators

A

> , <, <=, >=, ==, !=

19
Q

for loop

A

for item in sequence:

20
Q

range function

A

range(start, stop, step)
not inclusive of “stop”

21
Q

accumulator loops

A

initialize, iterate, update, report

22
Q

indexing

A

list[start:stop:step]
not inclusive of “stop”

23
Q

concatenating lists

A

list + list

24
Q

adding to lists

A

list.append

25
Q

length function

26
Q

split function

A

string.split()
splits a string on a space or other specified character and creates a list

27
Q

replace function

A

string.replace(a, b)
replaces all a with b

28
Q

strip function

A

string.strip()
removes all white space

29
Q

lower case / capital function

A

string.upper / string.lower

30
Q

checking for all numbers in a string

A

string.isdigit()

31
Q

checking for all letters in a string

A

string.isalpha()

32
Q

insert in a list

A

list.insert(position, element)

33
Q

remove from a list

A

list.remove(element)

34
Q

remove the last element from a list

A

list.pop()

35
Q

finding the index number

A

list.index(element)

36
Q

while loop

A

while condition:

37
Q

reading a CSV

A
  1. Create an empty list
  2. Use the with open function
  3. For row in file:
    a. List.append(row.strip())