try
and
except
:
we can go over them again in the future.
Read the course’s
grading policy.
Bookmark the
Python documentation
and the
course home page
in your browser.
Look at the documentation for the
built-in functions
we mentioned in class tonight:
round
,
len
,
int
,
print
,
input
,
etc.
The Python
round
function is implemented
in
the language C.
Create
a GitHub account if you don’t already have one.
To add a photo of yourself to your GitHub account,
pull down the triangle in the upper right corner,
select Settings,
and upload a picture.
Please email me (at
mark.meretzky@gmail.com
)
your name and the name of your GitHub account.
Then
admire
the other students’ GitHub accounts.
Here is the instructor’s
GitHub account
and his
WS19PB02-MarkMeretzky
organization left over from a previous semester.
The organization contains a repository named
flag
,
and the repository contains a file named
flag.py
.
This file is a Python script and we’ll talk about it
here.
Three differences between Python 2 and Python 3 we mentioned tonight (see Common Stumbling Blocks):
/
operator
gave you a truncated quotient.
In Python 3,
the
/
operator
gives you a quotient that is not truncated.
print
was a statement and needed no parentheses.
(I actually didn’t mention this.)
In
Python 3,
print
is a function and therefore needs parentheses.
input
function was named
raw_input
.
(To make matters worse, Python 2 also had another function named
input
.)
Complete your installation of Python on your Mac or PC by running the
Install certificates.command
which is alongside IDLE in the Python 3.7 folder.
Then uncomment (i.e., remove the
#
from)
the
print
in
line
54
of
ibm.py
in
exit status
and see if you print the current price of IBM stock.
Also uncomment the
print
in
line
68
of
temperature.py
and see if you print the current temperature in fahrenheit in New York City.
Create a GitHub organization named
SF19PB1-yourname
(with a dash),
where
yourname
is your GitHub loginname.
Follow
these instructions.
We will use a GitHub
organization
as a container to contain our
repositories.
Each repository will contain one Python program.
input
,
print
,
while
,
for
,
range
,
etc.
Create a repository in your Python organization (follow
these instructions)
and copy your interesting program into the repository.
Then
admire
the other students’ repositories.
Yes, IDLE has a debugger. “Still incomplete and somewhat experimental.”
Write an interesting Python program using the stuff we’ve been
covering in class.
I like programs that draw pictures.
If your program counts through a series of integers,
do it with a
for
loop,
not a
while
loop.
You could time how long the program
(or the non-interactive part of the program)
takes to run.
Save the program in a file whose name ends with
.py
.
Upload this file to its own GitHub repository in your SF19PB1 organization.
You get no credit for programs that are not uploaded to your SF19PB1
organization.
/Library/Frameworks/Python.framework/Versions/3.7/share/doc/python3.7/examples/Tools/pynche/X/rgb.txt
/Library/Frameworks/Python.framework/Versions/3.7/share/doc/python3.7/examples/Tools/pynche/X/rgb.txt
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/test/audiodata
pip3
install
).
statistics
module?
What was the (meaning and) purpose of the
[:,:,1]
we saw today in
the code
that changed the color image to black and white?
I put a list of audio files into
Loop.
Can you make a jukebox?
JC claims you can train
this Python package
to recognize images of dogs.
matplotlib.pyplot
,
sorting,
List comprehension.
Be sure to refresh the web pages.
print
function,
or as a
bar chart
or
pie
chart,
or spoken out loud.
“You don’t want to walk in this neighborhood because…”
Find a database whose records contains fields for latitude and longitude. (An example is Street Trees.) Write a Python program that will read the database from the web in CSV format and display some or all (probably only some!) of the records as pins in a Google map. Include a link to the map in the docstring at the start of the Python program when you upload the program to your GitHub organization.
b
in the first program in
Tic
already contains a winning position,
and,
if so,
who the winning players are.
You should also do the two exercises in
Plot.
(Even better, change the column of
S
s
and
P
s
to a column of
True
s
and
False
s.)
You should write a Python program that reads an online CSV database
if you have not already successfully done so.
tuple
s,
dict
ionaries,
and/or
list
s
of
list
s
(or
tuple
s
of
tuple
s).
dict
ionaries.
SHELL
now contains
/bin/bash
in a Python program run in
IDLE,
and
/bin/zsh
in a Python program run in the
Terminal
window.
Why two different shells?
And I simplified (or at least localized) the creation of the sorted
list
s
years
and
races
in
infant mortality.
Write something interesting,
probably with
dict
ionaries.
max
in exercise 2 of
Intersection.
To clarify this, I added some
max
examples
here.
I have a working example of
where
.
Make sure you understand
groupby one column
before you try to understand
groupby two columns.
Then write something interesting,
probably using
set
s,
dict
ionaries,
DataFrame
s,
and/or
Series
.
See the new exercise 4 in Download JSON. At 8:00 a.m. EST, it’s daytime in New York and nighttime in Seattle:
where
.
Compare
weather.py
with exercise 4 in
Download
JSON.
See the simple
itertools.combinations
example I added to
Limitations.
Do something interesting, probably involving a
function
definition.
Note that by the end of the course I will have asked you to write and upload
to GitHub approximately 30 python programs;
your grade depends on these 30 programs.
mypy
works on your Mac.
Can we configure IDLE so that it always feeds your Python program to
mypy
before running the Python program?
See the environment variable
$IDLESTARTUP
in
Startup
and code execution.
Write something interesting involving functions.
for
loops,
dict
,
collections.defaultdict
,
collections.Counter
,
and
max
with a
lambda
function.
Write and upload something interesting,
probably involving
attaching
attributes
to an
object.
__init__
and
__str__
.
The
__init__
method should store one or more
attributes
into the newborn object.
(How about
firstName
and
lastName
?
Or
temperature
,
humidity
,
and
windspeed
?
Or
bust
,
waist
,
and
hip
?)
Then create several objects,
call the
__str__
method of each object,
and print the return value of each call to the
__str__
method.
The course in room 8110 is CCNA (Cisco Certified Network Associate). Its teacher says that networking uses a lot of Python.
Date
to your GitHub organization.
pip3 search jupyter jupyter (1.0.0) - Jupyter metapackage. Install all the Jupyter components in one go. pip3 install jupyter jupyter --version jupyter --help
date
,
time
,
and
datetime
in the Python Standard Library are packaged in the module
datetime
.
Also write a Python program that
import
s
your module.
MyRange
,
FloatRange
,
and
week.range
examples in that page.
Then create an interesting
iterable.
I checked, and yes, the pandas
Series
and
DataFrame
are both iterable.