WGU D522 WITH 50 QUESTIONS & CORRECT
ANSWERS
title() - ANSWER-capitalizes first letter of each word
islower() - ANSWER-determines if the string consists of lowercase characters
count() - ANSWER-totals number of times an argument is found within a
predefined value
myNumbers = [1, 4.8, 7, 9.2, 3, 0] - ANSWER-creates a list
mylist[0] - ANSWER-accesses first element from a list
mylist[-1] - ANSWER-accesses last element from a list
mylist[1:3] - ANSWER-slices list including second and third element
mylist[:3] - ANSWER-slices list beginning with first element and including
through the third element. Index position 3 is not included in selection.
mylist[3:] - ANSWER-slices list beginning with fourth element and include
remainder of the list
sorted(listname, reverse=True) - ANSWER-returns copy of list ordered largest to
smallest
, append() - ANSWER-adds new value to end of list
pop() - ANSWER-removes last item from a list
pop(1) - ANSWER-removes second item from a list
join() - ANSWER-joins values from a list using a defined separator
open('/my_path/my_file.txt','r') - ANSWER-opens a file object for reading
open('/my_path/my_file.txt','w') - ANSWER-opens a file object for writing
read() - ANSWER-reads data from open file
close() - ANSWER-closes open file
write() - ANSWER-writes to open file
with open('/my_path/my_file.txt','r') as f: - ANSWER-opens a file, performs
operations and automatically closes file
r - ANSWER-read
w - ANSWER-write
ANSWERS
title() - ANSWER-capitalizes first letter of each word
islower() - ANSWER-determines if the string consists of lowercase characters
count() - ANSWER-totals number of times an argument is found within a
predefined value
myNumbers = [1, 4.8, 7, 9.2, 3, 0] - ANSWER-creates a list
mylist[0] - ANSWER-accesses first element from a list
mylist[-1] - ANSWER-accesses last element from a list
mylist[1:3] - ANSWER-slices list including second and third element
mylist[:3] - ANSWER-slices list beginning with first element and including
through the third element. Index position 3 is not included in selection.
mylist[3:] - ANSWER-slices list beginning with fourth element and include
remainder of the list
sorted(listname, reverse=True) - ANSWER-returns copy of list ordered largest to
smallest
, append() - ANSWER-adds new value to end of list
pop() - ANSWER-removes last item from a list
pop(1) - ANSWER-removes second item from a list
join() - ANSWER-joins values from a list using a defined separator
open('/my_path/my_file.txt','r') - ANSWER-opens a file object for reading
open('/my_path/my_file.txt','w') - ANSWER-opens a file object for writing
read() - ANSWER-reads data from open file
close() - ANSWER-closes open file
write() - ANSWER-writes to open file
with open('/my_path/my_file.txt','r') as f: - ANSWER-opens a file, performs
operations and automatically closes file
r - ANSWER-read
w - ANSWER-write