pt.2 Flashcards

1
Q

or, not, and

What is the order?

A

Not, And, Or

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

what does this function do?

del x[i]

A

deletes whatever the number or word is index in the list

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

x = [‘andrea’, ‘2’, ‘howdy’, ‘4’, ‘5’]
del x[1]
print(x)

Output?

A

deletes the 2

[‘andrea’, ‘howdy’, ‘4’, ‘5’]

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

x = [‘andrea’, ‘came’, ‘howdy’, ‘last’, ‘5’]
x.sort()
print(x)

Output?

A

[‘5’, ‘andrea’, ‘came’, ‘howdy’, ‘last’]

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

x = [24, 78, 1, 67, 90]
x.sort()
print(x)

Output?

A

[1, 24, 67, 78, 90]

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

What does the function ‘break’ do?

A

exists loop

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

what does the function ‘continue’ do?

A

skips to next iteration

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

How does a while loop work?

A

it will continue until the condition is false

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

how does a for loop work?

A

it will continue for certain amount of runs, you give it

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

File:

what does ‘r’ mean?

A

Read starting at the 0th line

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

File:

What does the ‘w’ mean?

A

starts writing at the 0th line

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

File:

what does the ‘a’ mean?

A

it appends at the last line

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

file:

with open(filename, mode) as file:

Does this automatically close file or do you have to close it yourself? If so, how? is it indented or not?

A

automatically

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

File:

file = open(filename, mode

Does this automatically close file or do you have to close it yourself? If so, how? is it indented or not?

A

yourself

file.close()

not indented

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

File:

How do we read a file?

A

file.read()

this reads all the data

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

How do we read one line in a file?

A

file.readline()

17
Q

What is the other way to read all the line in a file?

A

file.readlines()

18
Q

What are the two ways we write in a file?

A

file.write(str)

file.writelines(list[str])

19
Q

What are syntax errors?

A

misspelling

20
Q

Run- time error?

A

when you tell it do something but, you don’t have it

21
Q

Logic errors?

A

when your code runs, but gives you the wrong output?

22
Q

What does this mean:

“\n”

A

to write in a new line