|(as it would appear on official course roster)|
| Optional: name you wish to be called|
if different from name above.
| Optional: name of "homework buddy"|
(leaving this blank signifies "I worked alone"
h06: Perkovic 4.1-4.2 (Strings, Formatting)
|true||Tue 10/24 08:00AM||Tue 10/31 08:00AM|
You may collaborate on this homework with AT MOST one person, an optional "homework buddy".
MAY ONLY BE TURNED IN IN THE LECTURE/LAB LISTED ABOVE AS THE DUE DATE.
There is NO MAKEUP for missed assignments, and you may not submit work in advance, or on behalf of another person.
In place of that, we drop the four lowest scores (if you have zeros, those are the four lowest scores.)
Please read Perkovic 4.1-4.2 (Strings, Formatting). Then complete these problems.
(10 pts) Please fill in the information at the top of this homework sheet, including your name and umail address. If the other two items apply, please fill them in as well. Please do this every single time you submit homework for this class. It is important to fill in both name and umail every time, since handwriting is sometimes difficult to decipher. Having both helps us ensure you get credit for your work.
Also: while we strongly prefer that you submit your homework on a single sheet of paper, if you MUST submit it on multiple sheets, JUST write your name at the top of both sheets and turn in both sheets UNCONNECTED.
DO NOT staple, paper clip, spit-fold-and-tear, or do ANYTHING that would make it difficult to automatically feed your paper through a scanner.
Section 4.1 discusses indexing and slicing of strings, as well as some methods (functions) that can be invoked on strings.
Assume that the following assignment statements have been executed.
fname="Chris" lname="Gaucho" schools=["UCSB","Stanford","UCSD","Cal Poly"]
What will each of the expressions below evaluate to?
Points Expression Result Points Expression Result (5 pts)
(5 pts) In Python, how do we define a string that consists of more than one line of text?
(5 pts) For the Python code in the left box, write the output in the right box
the_list = ["8","16","24","32"] for course in the_list: print(course, end="|")
When you import the module
time, the function
time.time()gives “seconds since the epoch”, while
time.gmtimegives a representation of the time in UTC.
(5 pts) What is “the epoch”?
(5 pts) What is UTC?
(5 pts) If you want the local time instead of UTC, what function of the
timemodule do you call instead of
(5 pts) As shown on p. 106, if you enter
import timeat the
>>>prompt, then enter the following:
>>> time.strftime('%A %b/%d/%y %I:%M %p', time.localtime())
the resulting output is the current date and time in the format:
Tuesday Oct/24/17 11:59 AM
Using the table of values on p. 107 as a reference, how would you change the call to
strftimeabove to get the date in this format:
October 24, 2017