This course will introduce the core data structure of the Python programming ... And, the answer is only for hint . it is helpful for those student who haven't submit Assignment and who confused ... These five lines are the lines to do this particular assignment where we are ...
chapter 8 week 4 quiz
Get link
Facebook
X
Pinterest
Email
Other Apps
chapter 8 week 4 quiz
chapter 8 week 4 quiz
Quiz
How are "collection" variables different from normal variables?
Collection variables merge streams of output into a single stream
Collection variables can store multiple values in a single variable
Collection variables can only store a single value
Collection variables pull multiple network documents together
What are the Python keywords used to construct a loop to iterate through a list?
try / except
def / return
foreach / in
for / in
For the following list, how would you print out 'Sally'? friends = [ 'Joseph', 'Glenn', 'Sally' ]
print(friends[2])
print(friends[2:1])
print friends[3]
print(friends['Sally'])
What would the following Python code print out? fruit = 'Banana'
fruit[0] = 'b'
print(fruit)
Banana
banana
Nothing would print - the program fails with a traceback error
b
Which of the following Python statements would print out the length of a list stored in the variable data?
print(data.length())
print(length(data))
print(strlen(data))
print(len(data))
What type of data is produced when you call the range() function? x = list(range(5))
A string
A list of characters
A list of words
A list of integers
What does the following Python code print out? a = [1, 2, 3]
b = [4, 5, 6]
c = a + b
print(len(c))
6
21
[1,2,3]
[1,2,3,4,5,6]
Which of the following slicing operations will produce the list [12, 3]? t = [9, 41, 12, 3, 74, 15]
t[:]
t[1:3]
t[12:3]
t[2:4]
What list method adds a new item to the end of an existing list?
pop()
append()
add()
index()
What will the following Python code print out? friends = [ 'Joseph', 'Glenn', 'Sally' ] friends.sort()
print(friends[0])
9.4 Write a program to read through the mbox-short.txt and figure out who has sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail. The program creates a Python dictionary that maps the sender's mail address to a count of the number of times they appear in the file. After the dictionary is produced, the program reads through the dictionary using a maximum loop to find the most prolific committer. Answer:
10.2 Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages. You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon. From stephen.marquard@uct.ac.za Sat Jan 5 09 :14:16 2008 Once you have accumulated the counts for each hour, print out the counts, sorted by hour as shown below. Answer:
6.5 Write code using find() and string slicing (see section 6.10) to extract the number at the end of the line below. Convert the extracted value to a floating point number and print it out. Answer:
Comments
Post a Comment
if you have any doubt , please write comment