Spring 2022 -- Peter Brooks & Janet Vorobyeva
Challenge Problems (for if done in class).
Python Reference Sheet.
Final Project Gallery! |
Your projects are graded, and I've put up a gallery of links for you to peruse your
classmates' work.
Link to final project gallery |
Final Project: Pokedex
Phase 1 Due Mon 06/06 at 8:00am Final Version Due Fri 06/10 at midnight +3 Points if finished by Wed 06/08 at 8:00am |
Link to project instructions
Reminder, for the final submission, you must have:
|
HW19: Dictionaries
due Fri. 06/03 at 8:00am |
Here are some notes on dictionaries
Dictionaries HW Here are my answers Notes/Hints: General hints: you'll be using a dictionary to count occurences of various things.
In problem 1: the f.readline() is just a slightly different way to loop over the lines in the file. Don't worry about it, that code is equivalent to this: f = open(filename,'r') lines = f.read().strip().split("\n") for line in lines: if line.isdigit(): # make sure it's an integer string (e.g. "123") #do some stuff In problem 2: you can use char = char.upper() to change case. You can use ord(char) <= 127 to check if it's a valid character; |
HW18: Multipage HTML
addition due Thu 06/02 at 8:00am |
=== ADDITION WED 06/01 ===
ADD THE FOLLOWING TO YOUR SITE: - Download this zip file, which contains 10 images of numbers. - Unzip that, put the 'numbers' folder inside your hw18 folder - Modify your script to include an image of the appropriate number on each page - Modify your script to also generate an index.html file - index.html should have a link to each of the pages - each page should have a link back to index Bonus: - here's a way to add simple navbars to your site: Navbars - Add a navbar to the top of each page, containing a link to the index, and a dropdown of links to each individual page === END OF ADDITION === Homework 18: Using python to generate multi-page sites Here's a guide on transferring webpages to your public_html directory on homer. |
HW17: Real Data Analysis
due Tue. 05/31 at 8:00am |
NOTE: solutions to HW16 are now up. While I am out today, please work on the
following assignment. Note if your classmates are unaware
of this assignment, please let them know that there is work up on the homepage.
Today you will be working with a real dataset of SAT scores from NYC schools in 2012:
Bonus: If you're done try adding the following features:
Submit your .py file to the homework server as per usual. |
Python HW 16: HTML Revisited
due Fri. 05/27 at 8:00am |
Homework 16:
Using python to generate HTML from CSV data.
Remember you can use the string.strip() method to remove trailing whitespace. A common pattern is to read file data as fileLines = file.read().strip().split("\n") Also, for generating string output, you may find it useful to use the methods string.join(...) and string.format().
|
Python HW 15: Accounting Software
due Thu 05/26 at 8:00am |
Notes and examples for working with CSV files
Here's a name and wage file. With each person's name there is listed their: pay per day, their start date at work, and their last date of work. Save this file in the same directory as your .py file. Write a program to read in the file and answer the following questions. Put your answers in the comments-to-teacher box. Also upload your .py file as usual.
For testing your code, I recommend writing some test cases against a smaller dataset, like this one>. |
File reading classwork |
Download the following file: reverse_me.txt (open it, right click, "Save Page As")
Save the file in the same directory as your .py file, otherwise python will not be able to open it.
|
Lab: .split() Exercises
due Wed. 05/25 at 8:00am |
Today's Lab Assigment: More .split() exercises
For this assignment, in addition submitting your .py file, please also put your answers to each question in comments-to-teacher. As usual, mention who you worked with, how long it took, and whether all the test cases worked. Answers:
|
Python HW 13: Numeric Analysis
due Mon. 05/23 at 8:00am |
=== ADDITION FRI 05/20 ===
=== END OF ADDITION === Homework 13 Problems: Working with numbers and extracting summary statistics. NOTE: this is a function with many parts. Make sure you go through it one step at a time, as detailed in the assignment. Do the median last, if you can't get the median working in a reasonable timeframe, you should at least make sure you get all the other parts working. As usual, mention who you worked with, how long it took, and whether all the test cases worked. Here are my solutions (now with median!) |
Python HW 12: List Mutation
due Thu. 05/19 at 8:00am |
Here's a lists reference sheet that you may find useful.
Homework 12 Problems: Modifying lists and list aliasing. As usual, when you submit your .py file, please mention who you worked with on it (if anyone), how long it took you, and whether all of / which of the test cases worked. Here are my solutions |
Python HW 11:
String Methods and Documentation due Thu 05/11 at 8:00am |
Here is a link to the Python Standard Library Documentation. For today, you'll be looking at the section Text Sequence Type - str under Built-in Types.
For homework: read through the documentation for str.upper(), str.replace() For each of these, come up with test cases like the following: print('"apple".replace("p","ba") should be "ababale", is: ', "apple".replace("p","ba"))Make sure you write down what you expect the output to be BEFORE running your test case; this will force you to make a mental model of what the function does, which is helpful to undestanding. Write at least two test cases for each string method.
|
Python HW 10
due Wed 05/04 at 8:00am |
Homework 10 Problems: Character shifting and ciphers
Update on homework submission policy: when you submit your homework, make sure you also add the following to the comments-to-teacher box:
|
Python HW 09
due Tue 05/03 at 8:00am |
Homework 9 Problems. |
Python HW 08
due Fri 04/29 at 8:00am |
Homework 8 Problems, now with explanations.
Here are my solutions |
Python HW 07
due Wed 04/27 at 8:00am |
NOTE to PD5: I ended up removing findWord from the hw
and replacing it with 2 easier problems
Tonight please finish the Homework 7 Problems. In comments: how long it took at home, who you worked with in class. Here are my solutions Also, solutions to the "bookkeeper" problem from a few days ago |
Python HW 06
due Tue 04/26 at 8:00am |
UPDATE 04/14: Solutions to HW04 and HW05 are now posted below.
Homework 6 Problems. Problems related to string indexing, will be due after we get back from spring break. In comments: how long it took at home, who you worked with in class. Here are my solutions |
Python HW 05
due Wed 04/13 at 8:00am |
Homework 5 Problems.
Here's some problems related to strings. Once you're done, submit your .py file to the homework server. In the "comments-to teacher" box, put how long the hw took you to do (in decimal hours). Here are my solutions |
Python HW 04
due Sun 04/10 at midnight |
Homework 4 Problems.
Here's some problems related to the hailstone sequence / collatz conjecture that we looked at in class today. Once you're done, submit your .py file to the homework server. In the "comments-to teacher" box, put your answer to question 4, as well as how long the hw took you to do (in decimal hours). Here are my solutions |
Python HW 03
due Fri 04/08 at 8:00am |
Homework 3 Problems.
Work through these to figure out what they do. Once you're done, submit to the homework server in "comments-to teacher" how long it took you to do in decimal hours, and whether the output was as you expected or not. |
Quiz Review:
will be on Thu. 4/7 |
Quiz will be on Thursday, 4/7. Will be roughly 20 minutes long.
You are allowed a one-sided sheet of notes, no bigger than standard computer paper, which will be collected at the end of the quiz. Some topics to review (in no particular order):
|
Python HW 03
due Tue 4/05 at 11:59pm |
Consider the following code:
def foo(n): print("x") return(n * 10) print("y") print("a") i = 50 while i < 1000: i = foo(i) print("b") print(i)ON PAPER, WITHOUT using a computer: write down what you think this code will print. It may help you to keep track of variable values as you go. When you're done, check your answer with thonny: go through your own answer and figure out where it differs from the actual output and why. You don't need to submit anything for this, but you should work through it. We will be having a small quiz on thursday and this will be helpful for it. |
Python HW 02
due Sun 4/03 at 11:59pm |
Please complete the 2nd
Python homework.
Submit your .py file to the homework server.
|
Python HW 01
due Wed 3/30 at 8:00am |
Please complete the 1st
Python homework.
Submit your .py file to the homework server.
|
Challenge Problems | If you're done in class, try working on some of these problems. |
Notes for Tue 3/22
due Thu 3/24. |
Please do the following codingBat exercises.
Try to solve these WITHOUT using and, or, not, (which we haven't gone over class). Also for monkey_trouble, try solving it without doing a_smile == b_smile. Both of these would be a cleaner way to do it, but I would like you to try working with nested ifs, as that will hopefully be more helpful to you going forward. Some notes on if statements: # Assuming we have a numeric variable x if x > 10: return 1 # If test is True (above 10) else: return 2 # If test is False (not above 10) #Comparison operators: # Less/greater than: >, < # Less/greater than or equal to: >=, <= # Equal/not equal: ==, != # NOTE: a single equal '=' DOES NOT CHECK EQUALITY. # a single equal '=' assigns values to variables # Note: if we have variables a and b that hold # either True or False, we can test them directly without a comparison if a: if b: print("Both a and b are True") else: print("a is True, and not b") print("a is True") print("prints always") # True and False are values in python like 0 and 1 # Don't quote them: "True" is a string, (not what you want here) if a: return False |
Work 1: CodingBat
due Mon. 03/21 at midnight |
CodingBat is a site with Python (and Java) problems (as well as some additional
ones written by Mr. Konstantinovich). It lets you write
and test your code online, and we will be making use of it throughout the semester.
You should go to https://codingbat.com/home/konstans@stuy.edu/all and register for an account. One-time registration:
|
Work 0: Thonny
Do tonight, Thu 3/17. Nothing to submit |
Download Thonny onto your personal computer.
Write a hello world program: print("hello world"), and run it (Run > Run current script)
|
Personal Homepages are up! Voting homework due Sun midnight. |
I will be out the rest of this week (March 10th - 11th). Please use your class time to look at, discuss, and vote on your webpages. Voting rules:
|
HW: Internet Oddities
Homework due Fri 3/4 8AM (i.e. before class tomorrow) |
Come up with one way you've interacted with the internet that is not primarily
loading a webpage. Alternatively, think of a situation where the internet
seems to be doing something weird that can't be explained by the things we've been discussing in class.
(e.g. like when you try to connect to the wifi at starbucks
and it redirects your usual sites to a starbucks-specific wifi page)
Please write a few words or sentences describing your thing, and submit to the hw server in the comments-to-teacher box. |
Help from Ms. Vorobyeva | I can be found in the CS office (room 301). The best times to find me there are 6th period or after 10th. If you're willing to try your luck, I'll usually be free 8th period as well. Please come by anytime if you have questions. |
Sending Email to Ms. Vorobyeva: |
send mail to:
jvorob@stuy.edu Please include your name and class period in the subject line of your email. |
Ms. Vorobyeva (a.k.a. Ms. V) | Taking over from Mr. Brooks as of Wednesday, 3/2. |
The Internet and how it works | Here's a video about how a webpage requested by someone in England but located on a computer in Los Angeles gets to him. |
Personal
homepages graded task. Due Mon, 2/28, midnight. |
|
Friday: surprise quiz. | Shouldn't be too hard. You're responsible for all of the HTML we've covered, and the CSS material covered in the first 5 tutorials videos below. |
CSS tutorials online... |
- Here is the start of a sequence of
short video tutorials on CSS: Watch at least the first 5 videos
in the sequence. These are really good and very short, and the
rest of them -- the ones on "classes" (videos 6 and 7) and the ones
on fonts (8 and 9) as also good. Watch these, I recommend
them. - The videos assume that you're familiar with the HTML commands <h1> (a header type) and <p> (a paragraph), which we'll cover in class. - I will also cover <title> and how to access picture files that are in a different directory than your HTML file. - I will assume that you've seen the first 5 for CSS material that might be on Friday's quiz. |
CSS and Javascript. | A little bit about CSS and Javascript... |
Homework for Valentine's Day night (Mon, 2/14) |
|
Classwork for Thurs, 2/10 |
Work on creating a webpage that looks like this:
CopyThis.jpg You can have your own text, but the layout and visual effects should be the same. I want to see this on your computers in class on Friday. |
Finding and
using good HTML References and websites to learn from... Homework, due Wed. 2/9 midnight |
|
For Mac users of TextEdit |
TextEdit is a built-in editor for plain text files, but it
defaults to rendering HTML (like a browser), rather than display it
(like what you typed). You can set its Preferences to support
editing HTML:
On the Open & Save tab:
|
Thurs, Fri -- I'm out with a cold. |
Next week we'll start on HTML. After that, there'll be no
stopping us. Use today to relax, it may never happen again. |
Wed, 2/2: for Periods 9 & 10: I'm out today, but expect to be back tomorrow. |
- The entire class task is to register with the new Homework server
(set up your Profile, just like you did at the beginning of last
semester) and test your new password. - Instructions below. - Please help those students who didn't have me last semester. |
First task: fill out your Profile on the Homework server. |
|
Help from Mr. Brooks | In school, I live in the CS nest (room 301). I'm free periods 6,7,8. Come on in, no appointment necessary. If I'm busy, we'll work out a time. If I'm not there, ask someone when I'll be back and/or try reaching me telepathically. |
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 | |
Mr. Brooks | MicroMind, Inc. |