pt.2 Flashcards
or, not, and
What is the order?
Not, And, Or
what does this function do?
del x[i]
deletes whatever the number or word is index in the list
x = [‘andrea’, ‘2’, ‘howdy’, ‘4’, ‘5’]
del x[1]
print(x)
Output?
deletes the 2
[‘andrea’, ‘howdy’, ‘4’, ‘5’]
x = [‘andrea’, ‘came’, ‘howdy’, ‘last’, ‘5’]
x.sort()
print(x)
Output?
[‘5’, ‘andrea’, ‘came’, ‘howdy’, ‘last’]
x = [24, 78, 1, 67, 90]
x.sort()
print(x)
Output?
[1, 24, 67, 78, 90]
What does the function ‘break’ do?
exists loop
what does the function ‘continue’ do?
skips to next iteration
How does a while loop work?
it will continue until the condition is false
how does a for loop work?
it will continue for certain amount of runs, you give it
File:
what does ‘r’ mean?
Read starting at the 0th line
File:
What does the ‘w’ mean?
starts writing at the 0th line
File:
what does the ‘a’ mean?
it appends at the last line
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?
automatically
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?
yourself
file.close()
not indented
File:
How do we read a file?
file.read()
this reads all the data