Just Python Things Flashcards
(9 cards)
1
Q
strip()
A
removes the leading and the trailing whitespaces
eg
some_string.strip()
2
Q
line = “ the woman has the sword of world the”
print(line.strip(“ the”))
A
woman_has_the_sword_of_world
3
Q
ord(“Z”)
A
90
the ASCII value
4
Q
some_variable = some_string.split(“,”)
A
splits some_string into different parts and returns list
5
Q
sorted(some_list)
A
sorts the some_list
6
Q
def print_first_word(words): word = words.pop(0) print(word)
A
Prints the first word after popping it off
7
Q
def print_first_word(words): word = words.pop(-1) print(word)
A
Prints the last word after popping it off
8
Q
def brake_words(stuff): """What's this?"""#What's the use of this line words=stuff.split(' ') return words
A
#after importing the file.py and typing help(file.brake_words) #prints What's this its like the discription of the function
9
Q
def brake_words(stuff): """What's this?"""#What's the use of this line words=stuff.split(' ') return words
A
#after importing the file.py and typing help(file.brake_words) #prints What's this its like the discription of the function