Part 1 Flashcards

Learn the basics

1
Q

Read a line from text file to variable

A

line = file.readline()

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

Define a function that returns a variable

A
def function(a):
    return(a)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

break a string into a list of words, save into variable

A

str_list = “a-b-c-d -e -“.split(‘-‘)

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

sort a list

A

string = sorted(list)

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