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 6 week 1 quiz
Get link
Facebook
X
Pinterest
Email
Other Apps
chapter 6 week 1 quiz
chapter 6 week 1 quiz
Quiz
What does the following Python Program print out? str1 = "Hello"
str2 = "there"
bob = str1 + str2
print(bob)
Hello there
Hello
Hello there
Hellothere
What does the following Python program print out? x = '40'
y = int(x) + 2
print(y)
x2
42
int402
402
How would you use the index operator [] to print out the letter q from the following string? x = 'From marquard@uct.ac.za'
print(x[9])
print(x[8])
print(x[7])
print x[-1]
How would you use string slicing [:] to print out 'uct' from the following string? x = 'From marquard@uct.ac.za'
print(x[14:17])
print(x[14/17])
print(x[14+17])
print(x[15:18])
What is the iteration variable in the following Python code? for letter in 'banana' :
print(letter)
letter
print
'banana'
for
What does the following Python code print out? print(len('banana')*7)
bananabananabananabananabananabananabanana
0
42
banana7
How would you print out the following variable in all upper case in Python? greet = 'Hello Bob'
puts(greet.ucase);
console.log(greet.toUpperCase());
print(uc($greet))
print(greet.upper())
Which of the following is not a valid string method in Python?
twist()
startswith()
join()
split()
What will the following Python code print out? data = 'From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008'
pos = data.find('.')
print(data[pos:pos+3])
.ma
Sat
uct
mar
Which of the following string methods removes whitespace from both the beginning and end of a string?
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