Spring 2021 -- Peter Brooks
Some Python documentation... |
|
Course Final Project. Due Sat, June 12, midnight. |
Here are the particulars... |
Strange Digits - Homework, Due: Mon, 6/7 (pds. 3,4) Tue, 6/8, (pds. 9,10) |
Mother Nature likes some numbers more than others. See it with
your own eyes! Homework is here. Answers are here. |
Matplotlib! A graphing library in Python. Homework: Due: Wed, 6/2 (pds 3,4) Fri, 6/4 (pds 9,10) |
Here's an introduction to
Matplotlib. If the images don't show up, check your <img> tags -- they should NOT start with "file://" because that refers to files ONLY on your computer. |
Quick review on uploading webpages |
Quick review on uploading webpages and images to moe
(read all instructions before starting): 3. You should now be able to type the following url in your browser to display the page: http://moe.stuy.edu/~voldy-1/chaos.html |
Creating scalable and rotatable shapes for turtles |
Download this Python program:
ShapeMaker.txt Read the documentation inside the file about the 2 functions you can use: 1) Create and store a shape using the MakeOne(filename) function 2) Load that stored shape into the turtle.register_shape() function to be used by turtles. |
Turtles!!! Yes, turtles in Python Due: Wed, 5/26 (pds. 3,4) Thurs, (pds 9,10) |
Here are
turtle docs,
4 tutorial
videos (not bad),
color-names chart. Creating transparent areas in externally produced turtle shapes (using paint programs): here are two video explanations of how to use external sites to solve the transparency problem, from our own Yong Qi Lin: vid1 & vid2. A. Download the following .Zip file (right-click, save as) and unpack the 5 files into a folder that you can remember. B. Load the turtles-tut-1.py file into Thonny, or IDLE, or VScode, or your back pocket or wherever fine Python code is run. There are 3 demos. Homework: 1. Create the function RandomSquare(sidelength, color_name), which will choose a random place on the screen to draw a square (not filled in) with the given sidelength and given color-name. 2. Create the function FilledHexagon(sidelength,border-color,fill-color) which will draw an hexagon, centered at the origin, with the given sidelength and border-color and fill-color (the 2nd of the 4 tutorial videos above talks about this). |
Dictionaries Due: Mon 5/24 (pds. 3,4) Tue 5/25 (pds, 9,10) |
A little tutorial on
dictionaries... Here's the dictionary homework. Here are my answers... |
Let's play with spreadsheets. Due: Tues, 5/18 (pds 3,4) Wed, 5/19 (pds 9,10) |
Try to obtain Microsoft Excel -- you should have rights to it
as an upstanding (or reclining) NYC student. But you may use Google sheets for these exercises. For the exercises below, I'll be asking you to find answers, but also I want to know (very briefly) what operations you did to get them. So, in the Comments-to-Teacher, enter the answer, and then the operations that got you there. For instance: "Q87. answer is 25.9, added cols B and F to G, sorted G, danced, removed rows with G values greater than 18, used '=average(G2:G32)'" Download the "names-1.txt" file, but change its suffix to ".csv". You'll notice that the data looks familiar. Load into Excel or Sheets. 1. Calculate the total pay for each person (you do not have to report all those payments, just report your speadsheets steps). 2. Calculate and report the average and median pay for all workers. 3. Report one of the workers with the longest name and one who worked longest. 4. How many workers started working and also ended working on even numbered days (Excel has a MOD() function, Sheets has REMAINDER()) 5. Challenge: how many names end with "A"? |
Spreadsheets: classwork... |
The World Happiness Report (ending at 2019). |
Hunting and gathering CSV datasets Due Fri 5/7 (pds. 3,4) Mon 5/10, (pds 9,10) |
Add yours
here. We'll be covering, in class, how to find the median school name and median SAT total score from the 2012 SAT dataset on NYC Open Data. Try to do this yourself, first. |
File Reading/Writing and string/number conversion Homework due: Thurs: 4/29 (pds 3,4) Fri: 4/30 (pds 9,10) |
Reading and working with CSV files. Here's a name and wage file. With each name is included that person's pay/day and the start day of their employment and the last day of their employment. Answer the following questions and put the answers into the Comments-to-Teacher, and also upload your code file (do not paste code into the Comments-to-Teacher): 1. Which person made the most total money on this job? How much did they make? 2. List of people who worked the fewest days, and the number of days they (each) worked. 3. What was the average amount that these workers earned on this job (the total amount they took home)? |
Thinking about APCS... |
Mr. Holmes has written an excellent essay, which y'all should read:
Is Advanced Placement Computer Science at Stuy for You? There's a possibility of a new CS course -- to be given at the same time as APCS. Please fill out the following questionnaire |
It's test time! Actually test-test time. Your Python Test-Test is due: Fri. 4/23 morning (pds 3,4) Sat. 4/24 morning (pds 9,10) |
Here be the details. |
Python libraries | Python library documentation is here. |
.split() and .join() CSV exercises, due: Thurs 4/15 (pds 3,4) Fri, 4/16 (pds 9,10) |
.split() and .join are very useful string methods.
Here's how they work. A lot of data comes in .CSV format (Comma-Separated Values). Here's a first set of exercises that asks you to process such data... .split() exercises. split() exercises-answers |
Ah, lists... Homework due: Tue, 4/13 (pds 3,4) Wed, 4/14 (pds 9,10) |
Once you know about strings, indexing and slicing, lists are an easy
extension. LISTS List homework #1 List homework answers. |
Even more on strings... |
|
Strings, strings, more strings Due Wed 4/7 (pd 2,3), Thurs (pd 9, 10). |
We take a look at string methods, like
.upper() and .find() and can
use them for string transformations, like encryption. Do the following string exercises, which will be due after the break. Here are my answers. |
Letter coding Due on CodingBat Wed 3/24 (pds 3,4), Thurs 3/25 (pds 9,10) |
ASCII codes
and
Unicodes
are ways of
storing characters as numbers. You can find the code for a
letter (e.g. for ASCII code for "A" is 65) using
ord("A") -> 65, and in reverse, chr(65) -> "A" You can then "shift" each upper-case character in a word forward by one (e.g. "A" -> "B", and "B" -> "C", ... "Z" -> "A") with def ShiftUppercase(c): if c == "Z": return "A" return chr(ord(c) + 1) Do the CodingBat exercises: shiftCharacterByOne, shiftCharacter, shiftWordByOne, shiftWord |
Using for and
range() for looping. Python #3 homework due 3/22 8:00a for pds 3,4 3/23 8:00a for pds 9,10 |
Here are
examples of the use of
for
and range()
to create loops. Also, here is the use of
break
to terminate a loop prematurely. In a belated celebration of Pi day (yes, we missed it... why didn't y'all say something ... huh?), we'll have Pi calculations. Yes! Here are a couple of exercises, plus optional (if you really like math) problems having to do with Pi. My answers are here. |
Strings, and more strings. Homework due before next meeting (Thurs or Fri, 3/18,19) |
|
We're starting to work with CodingBat |
CodingBat (with Mr. Konstantinovich's additions) is a site with
Python (and Java) problems, and has an online tester.
|
Python homework #2: Due (periods 3,4): Wed 8:00 (periods 9,10): Thurs 8:00 |
Homework is
here. Answers are here. Remember that there are many ways to solve these problems correctly, and my answers are not unique, nor necessarily the best. |
Personal homepages are up! Voting due by Thurs night, 3/11 |
Vote for the 2 best homepages on the form HERE... First of all, most of these webpages, competitive and non-, were an enormous amount of work (yes, I know). And the outpouring of sheer creativity never fails to make me proud of the students in this course. A quiet thank-you to you all.
The Big Nos: No you can't vote for yourself; No, you can't vote for the same person twice; No, you can't vote for someone in another class; No, you can't sell your vote (or barter). 1st prize is 2 extra points on final course grade (except over 100); 2nd prize: 1 extra point. |
First Python homework Due (periods 3,4): Mon 8:00 (periods 9,10) Tue 8:00 |
Download this file (python-demo-1.txt),
then change its suffix from ".txt" to ".py" and then load it into
Thonny Python exercises #1 Answers are Here. |
Python!
Thonny! For Tues/Wed, 3/2,3/3 classtime |
Download, install, and run Thonny, our preferred Python development environment (although you can use others). |
Privacy, security and
passwords Files/Directories, directory trees |
|
Wed/Thurs, 2/24-25: Imitate this page task |
In your breakout rooms, collectively figure out how to imitate this
page. Here are the
notes/suggestions for doing so, and
here's the good ol'
duckCat.jpg. Here's the actual webpage, so that you can View-Source and see the HTML and CSS I used to create it. |
Homework #3, Your personal homepage: to be finished by Sun 2/28 night. |
Create a webpage or set of webpages about yourself.
You can talk about /show your interests, hobbies, sports, music, etc. This will be published on moe.stuy.edu one of our CS dept. servers. Rules: you may NOT use a web-authoring program (like DreamWeaver) -- just a text-editor. You must write all of your own HTML and CSS code. -- you may not use packaged javascript or css files/libraries. Put the URL of your page (e.g. here's a simple one about Mr. Brooks's books http://moe.stuy.edu/~pbrooks/books/BookPage.html) into the Comments-to-Teacher, along with a sentence or two about your experience in creating it. Also, add whether you want to enter it into the class competition . If you say nothing, you won't be entered, but your URL will still be posted on the competition page (just like in the Shape/locomotion competition). |
Daily Double Digital |
The Daily Double Digital is a 4-minute presentation on any digital
topic that would be of interest to the class. Be prepared for
a couple of minutes of questions. There will be 2 presentations at the beginning of each class period. The Schedule is here. It is your responsibility to know when you're up. If you need to cancel, provide me the reason for it at least a day in advance, otherwise it's a no-show. |
Connecting to our CS server |
You'll be connecting to the computer:
moe.stuy.edu
You can use one of several free File Transfer Programs: FileZilla (Windows, Mac & Linux), or WinSCP (Windows only) In FileZilla, the settings are: host: moe.stuy.edu username: your user name, like hpotter30 password: your password port: 22 |
HTML/CSS References and Resources |
Here are the great resources that y'all found out there. These
will be useful for constructing your personal homepage(s). Period 3's finds Period 4's finds Period 9's finds Periods 10's finds |
Homework #2,
due: Wed 2/10 8:00 for periods 3,4 Thurs 2/11 8:00 for periods 9,10 |
Create a document like this for all of the HTML (and any CSS) codes that we have covered. Save that document in .PDF format and submit to the homework server. I'd gently recommend changing my name to yours. |
Homework #1, due 8:00a before next class |
Check out the W3Schools site -- learn to use it. Find and report on a good source of HTML and CSS information other than W3Schools, that's perhaps easier to work with, or has some other advantage. Post its URL in the Comments-to-Teacher, and say why it's better in some way. |
For Mac users of TextEdit: |
TextEdit is the built-in editor for plain text files, but it
defaults to rendering html, rather than displaying it. You can set
its preferences to support editing html: In the menu TextEdit > Preferences, on the New Document tab
|
First task: fill out your Profile on the Homework server. |
|
Help from Mr. Brooks | Feel free to come to the class
Rocket.chat channel: #office-hours during office hours or make an
appointment with me by email. Office Hours Zoom (sometimes) -- preferably, send me email beforehand if you will want to Zoom-talk... I will also be on the Rocket.chat channel: office-hours https://us02web.zoom.us/j/81151131539?pwd=Y0JuVWpGYXlyQnBrVFg4dzJUWFFXdz09 Meeting ID: 811 5113 1539 Passcode: 235232 |
Sending email to Mr. Brooks: |
Send mail to:
pbrooks@stuy.edu You MUST include your name in the subject line or body of the message, otherwise I won't know who it's from. |
Stuyvesant bell schedule | |
Homework/grade server |