General Notes


Submit the following programs via Gradescope:


  1. Due Date: 6 February Reading: Think CS: Chapters 1 & 2 & Lab1

    Write a program that prints "Hello, World!" to the screen.

    Hint: See the Lab 1.

  2. Due Date: 7 February Reading: Think CS: Chapter 4 & Lab1

    Write a program that draws an decagon (10-sided polygon).

    Note: Whenever submitting a turtle program, choose a name for your file that is not turtle.py. When executing the "import turtle" statement, the computer first looks in the folder where the file is saved for the turtle module and then in the libraries (and other places on the path). So, it thinks the module is itself, causing all kinds of errors. To avoid this, name your program something like "myTurtle.py" or "program2.py".

    Hint: See the Lab 1.

  3. Due Date: 10 February Reading: Think CS: Chapter 4 & Lab1

    Copy the program from Section 4.3 into a file on your computer and modify the program (with turtles tess and alex) to have a pink background color and have tess draw a blue square and alex draw a triangle:

    Note: Do not invert the order in which the turtles draw, only invert their shape (i.e. tess goes first, then alex). Also, keep the distance each turtle moves forward the same (tess goes forward 80 steps, alex goes forward 50 steps), only change the number of edges and degrees to change the shape.

  4. Due Date: 11 February Reading: Think CS: Section 4.7 & Lab1

    You can tell a turtle, let's call it tess, to move without drawing a line by lifting the pen up with tess.penup() and then tell it to move.

    You can then tell a turtle to start writing again when moving by putting the pen down with tess.pendown()

    Write a program that implements the pseudocode ("informal high-level description of the operating principle of a computer program or other algorithm") below:

        Repeat i 150 times:
            Walk forward 0.5*i steps
            Lift the pen up
            Walk forward 0.5*i steps
            Put the pen down
            Turn left 110 degrees
    
    
    Your output should look similar to:
  5. Due Date: 13 February Reading: Think CS: Section 4.7 & Lab1

    Write a program that will print your email 15 times.

    For example, the output of a member of the CSCI 127 staff program should be:

    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    huntercsci127help@gmail.com
    

    Note: the grading scripts expect the email associated with your Gradescope account. If you get an error that the email does not match, compare carefully the email you printed and the email on file. If your email is not correct on Gradescope, send email to hunterCSci127help AT gmail.com with the correct email.

  6. Due Date: 14 February Reading: Think CS: Chapter 2 and and Section 4.7 & Lab2

    Write a program that prints out the even numbers from 0 to 24.

    The output of your program should be:

    0
    2
    4
    6
    8
    10
    12
    14
    16
    18
    20
    22
    24
    

    Hint: Use the step option in the range() function

  7. Due Date: 18 February Reading: Think CS: Chapters 2 & 9 & Lab 2

    Using the string commands introduced in Lab 2, write a Python program that prompts the user for a message, and then prints the message, the message in upper case letters, the message in lower case letters and the number of characters in the message.

    A sample run of your program should look like:

    Enter a message:  Mihi cura futuri
    Mihi cura futuri
    MIHI CURA FUTURI
    mihi cura futuri
    16
    

    Another run:

    Enter a message:  I love Python!
    I love Python!
    I LOVE PYTHON!
    i love python!
    14
    

    Hint: Your program should be able to take any phrase the user enters. To do that, you need to store the phrase in a variable and print variations of the stored variable.

  8. Due Date: 19 February Reading: Think CS: Chapters 2 & 9 & Lab 2

    Write a program that prompts the user to enter a phrase, then print the phrase backwards.

    A sample run of your program should look like:

    Enter a phrase:  I love Python!
    !nohtyP evol I
    

    And another sample run:

    Enter a phrase: ABCDE
    EDCBA
    

    Hint: Loop backwards and print the string character at the loop index. You can tell print not to go to a new line by using the empty string as the end character. For example, with a string variable phrase you can print the first character without going to the next line using print(phrase[0], end='')
    See Lab 2.

  9. Due Date: 20 February Reading: Think CS: Chapters 2 & 9 & Lab 2


    (The cipher disk above shifts 'A' to 'N', 'B' to 'O', ... 'Z' to 'M', or a shift of 13. From secretcodebreaker.com.)

    Write a program that prompts the user to enter a word and then prints out the word with each letter shifted right by 16, differently from the image which shifts by 13. That is, 'a' becomes 'q', 'b' becomes 'r', ... 'y' becomes 'o', and 'z' becomes 'p'.

    Assume that all inputted words are in lower case letters: 'a',...,'z'.

    A sample run of your program should look like:

    Enter a word: zebra
    Your word in code is:
    purhq
    

    Hint: See the example programs from Lecture 2 (Lecture slides can be found on the course outline).

  10. Due Date: 21 February Reading: Think CS: Chapter 2 & Lab 2

    Write a program that prompts the user for a DNA string, and then prints the length and GC-content (percent of the string that is G or C, written as a decimal), as well as the position (index) of the first G and the first C

    A sample run of your program should look like:

    Enter a DNA string:  ACGCCCGGGATG
    Length is 12
    GC-content is 0.75
    First G found at position 2
    First C found at position 1
    

    And another sample run:

    Enter a DNA string:  AAAAA
    Length is 5
    GC-content is 0.0
    First G found at position -1
    First C found at position -1
    

    Hint: See Lab 2.

  11. Due Date: 24 February Reading: Think CS: Sections 2.7 & 9.5

    Write a program that asks the user for a noun and two verbs (inspired by a Colgate University COSC 101 program). Using the words the user entered, print out a new sentence of the form:

    	If it VERB1 like a NOUN and VERB2 like a NOUN, it probably is a NOUN.
    	
    A sample run of the program:
    Enter a noun: duck
    Enter a verb: walks
    Enter another verb: talks
    
    New sentence:
    If it walks like a duck and talks like a duck, it probably is a duck.
    
    Another sample run of the program:
    Enter a noun: cat
    Enter a verb: sounds
    Enter another verb: moves
    
    New sentence:
    If it sounds like a cat and moves like a cat, it probably is a cat.
    

    Hint: Here's a way to approach the problem:

    1. Create a variable, template and store the string "If it VERB1 like a NOUN and VERB2 like a NOUN, it probably is a NOUN." in it.
    2. Ask the user for a noun and store it in a variable, noun.
    3. Replace the placeholder in the template with the noun the user entered (i.e. template = template.replace("NOUN", noun)).
    4. Ask the user for a verb and store it in a variable, verb1.
    5. Replace the placeholder in the template with the verb the user entered.
    6. Ask the user for another verb and store it in a variable, verb2.
    7. Replace the placeholder in the template with the second the verb the user entered.
    8. Print out the updated template string.
  12. Due Date: 25 February Reading: Think CS: Chapter 4 & Lab 3

    Modify the program from Lab 3 to show the shades of purple.

    Your output should look similar to:

  13. Due Date: 26 February Reading: Think CS: Section 8.10 & Datacamp Numpy Tutorial & Lab 3

    Write a program that asks the user for a name of an image .png file and the name of an output file. Your program should create a new image that has only the green channel of the original image (that is, no red and blue channels).

    To test your program you can download csBridge.png

    A sample run of your program should look like:

    Enter name of the input file:  csBridge.png
    Enter name of the output file:  greenH.png
    

    Sample input and resulting output files:

    Note: before submitting your program for grading, remove the commands that show the image (i.e. the ones that pop up the graphics window with the image). The program is graded on a server on the cloud and does not have a graphics window, so, the plt.show() and plt.imshow() commands will give an error. Instead, the files your program produces are compared pixel-by-pixel to the answer to check for correctness.

    Hint: See Lab 3.

  14. Due Date: 27 February Reading: Think CS: Chapter 2 & Section 8.2 & Lab 3

    In Lecture 4, we designed a program to make a Hunter logo 'H' on a 10x10 grid. Write a program that creates a red 'U' logo for University on a 30x30 grid.

    The grading script is expecting:

    • The file to be saved as: logo.png.
    • The grid to be 30 x 30.
    • The 'U' to be 100% red, 0% green, and 0% blue. The lower part of the 'U' should be the lower third of the image; the left part of the 'U' should be the left third of the image; and the right part of the 'U' should be the the right third of the image.
    • The remaining pixels in the image should be white (100% red, 100% green, and 100% blue).

    Note: before submitting your program for grading, remove the commands that show the image (i.e. the ones that pop up the graphics window with the image). The program is graded on a server on the cloud and does not have a graphics window, so, the plt.show() and plt.imshow() commands will give an error. Instead, the files your program produces are compared pixel-by-pixel to the answer to check for correctness.

    Hint: See notes from Lecture 4. (Lecture slides can be found on the course outline)

  15. Due Date: 28 February Reading: Think CS: Chapters 2 & 9, Lab 2 & Lab 4

    Write a program that asks the user for a message and then prints the message out, five copies of each character per line surrounded by three stars '***' on each side.

    A sample run of your program should look like:

      Enter a message: I love Python!
      *** I I I I I ***
      ***           ***
      *** l l l l l ***
      *** o o o o o ***
      *** v v v v v ***
      *** e e e e e ***
      ***           ***
      *** P P P P P ***
      *** y y y y y ***
      *** t t t t t ***
      *** h h h h h ***
      *** o o o o o ***
      *** n n n n n ***
      *** ! ! ! ! ! ***
      

    And another sample run:

        Enter a message: Mihi cura futuri
        *** M M M M M ***
        *** i i i i i ***
        *** h h h h h ***
        *** i i i i i ***
        ***           ***
        *** c c c c c ***
        *** u u u u u ***
        *** r r r r r ***
        *** a a a a a ***
        ***           ***
        *** f f f f f ***
        *** u u u u u ***
        *** t t t t t ***
        *** u u u u u ***
        *** r r r r r ***
        *** i i i i i ***
      

    Note: The print() command can take multiple inputs to print at the same time. For example, print(c,c) will print the contents of variable c twice. For example, if c is "I", then it would print: I I.

    Hint: See Lab 2 or Lecture 2 notes.

  16. Due Date: 2 March Reading: Think CS: Chapter 2 & Lab 4

    Write a program that converts kilograms to pounds. Your program should prompt the user for the number of kilograms and then print out the number of pounds.

    A useful formula: lb = 2.20462262185 * kg.

    See Lab 4 for designing Input-Process-Output programs.

  17. Due Date: 3 March Reading: Think CS: Chapters 2 & 8.10 & Datacamp Numpy Tutorial & Lab 4

    Modify the flood map of NYC from Lab 4 to color the region of the map with elevation greater than 6 feet and less than or equal 20 feet above sea level the color grey (50% red, 50% green, and 50% blue).

    Your resulting map should look like:

    and be saved to a file called floodMap.png.

    Note: before submitting your program for grading, remove the commands that show the image (i.e. the ones that pop up the graphics window with the image). The program is graded on a server on the cloud and does not have a graphics window, so, the plt.imshow() and plt.show() commands will give an error. Instead, the files your program produces are compared pixel-by-pixel to the answer to check for correctness.

  18. Due Date: 4 March Reading: Think CS: Section 2.7 & Lab 4

    Write a program that implements the pseudocode below:

    1.  Ask the user for the number of cents as an integer (e.g. 99 not 0.99).
    2.  Print out the number of quarters (quarters = cents // 25).
    3.  Compute the remaining change (rem = cents % 25).
    4.  Print out the number of dimes (dimes = rem // 10).
    5.  Compute the remaining change (rem = rem % 10).
    6.  Print out the number of nickels (nickels = rem // 5).
    7.  Print out the remaining cents (cents = rem % 5).
    

    Be sure to print how many of each coin type in the given order (quarters, followed by dimes, followed by nickels, followed by cents) each on a new line.

    A sample run of your program should look like:

    Enter the number of cents: 99
    Quarters: 3
    Dimes: 2
    Nickels: 0
    Cents: 4
    

    and another sample run:

    Enter the number of cents: 62
    Quarters: 2
    Dimes: 1
    Nickels: 0
    Cents: 2
    

    Hint: See Section 2.7.

  19. Due Date: 5 March Reading: Think CS: Chapter 4, Lab1 & Lab 4

    Write a program that implements the following pseudocode using turtles:

        Ask the user for number of stamps
        Set the turtle shape to 'turtle'
        Lift the pen up
        Set steps to 20
        Repeat 'stamp' times:
            Stamp
            Increment steps by 2
            Move forward by steps
            Turn right by 24 degrees
      

    A sample run of your program should look like:

    Please enter the number of turtle stamps: 50
    

    and the output should look similar to:

  20. Due Date: 6 March Reading: Think CS: Section 8.10 & Datacamp Numpy Tutorial, Lab 3 & Lab 4

    Write a program that creates an image of blue and white vertical stripes. Your program should ask the user for the size of your image, the name of the output file, and create a .png file of stripes. For example, if the user enters 10, your program should create a 10x10 image, alternating between blue and white stripes.

    A sample run of the program:

      Enter the size: 11
      Enter output file: 11stripes.png
      

    Another sample run of the program:

      Enter the size: 50
      Enter output file: 50stripes.png
      

    Note: before submitting your program for grading, remove the commands that show the image (i.e. the ones that pop up the graphics window with the image). The program is graded on a server on the cloud and does not have a graphics window, so, the plt.show() and plt.imshow() commands will give an error. Instead, the files your program produces are compared pixel-by-pixel to the answer to check for correctness.

    Hint: See notes from Lecture 4.

  21. Due Date: 9 March Reading: Section 10.24 & Lab 2

    Write a program that prompts the user to enter a list of names. Each person's name is separated from the next by a comma and a space (', ') and the names are entered lastName firstName (i.e. separated by ' '). Your program should then print out the names, one per line, with the first initial of the first name, followed by ".", and followed by the last name.

    A sample run of your program should look like:

    Please enter your list of names:  Easley Annie, Wilkes Mary-Ann, Goldberg Adele, Spark-Jones Karen
    
    You entered:
    
    A. Easley
    M. Wilkes
    A. Goldberg
    K. Spark-Jones
    
          

    Hint: See Section 10.24 for a quick overview of split(). Do this problem in parts: first, split the list by person (what should the delimiter be?). Then, split each of person's name into first and last name (what should the delimiter be here?). Keep in mind that there is a space after the comma as well as between first and last name! If you have a string str, what is s = str[0] + "."?

  22. Due Date: 10 March Reading: Think CS: Chapter 4, Lab1, Lab 2 & Lab 4

    Write a program that implements the pseudocode below:

        Ask user for number of turns
        For i = 0, 2, 4, ... , turns-1:
            Walk forward i steps
            Turn right 45 degrees
    
    Your output should look similar to:

    Hint: See examples of range(start,stop,step) in Lecture 2 notes (found on the Course Outline) and Lab 2.

  23. Due Date: 11 March Reading: Think CS: Chapters 7 & 8.10 & Datacamp Numpy Tutorial & Lab 5

    Following Lab 5, write a program that asks the user for the name of a .png file and print the number of pixels that are nearly white (the fraction of red, the fraction of green, and the fraction of blue are all above 0.75).

    For example, if your file was of the snow pack in the Sierra Nevada mountains in California in September 2014:

    then a sample run would be:

    Enter file name:  caDrought2014.png
    Snow count is 38010

    Note: for this program, you only need to compute the snow count. Showing the image will confuse the grading script, since it's only expecting the snow count.

  24. Due Date: 12 March Reading: Burch's Logic & Circuits

    Write a logical expression that is equivalent to the Exclusive OR gate on 2 inputs, called in1, in2:

    • If either one or the other (but not both) input is True, then your expression should evaluate to True.
    • Otherwise (both inputs are True or both inputs are False), then your expression should evaluate to False.

    Save your expression to a text file. See Lab 5 for the format for submitting logical expressions to Gradescope.

  25. Due Date: 13 March Reading: Think CS: Chapters 7 & 8.10 & Datacamp Numpy Tutorial & Lab 4

    Modify the map-mapking program from Lab 4 to create a topographic map (highlighting the points that have elevations that are multiples of 10). Your program should ask the user for the amount of blue (a floating point number between 0.0 and 1.0), the name of the output image, create a new image with that name and with the pixels colored as follows:

    • If the elevation is less than or equal to -10 (deep below sea level), color the pixel dark gray (20% red, 20% green, 20% blue).
    • If the elevation is less than or equal to 0 (below sea level but not so deep), color the pixel the amount blue the user specified (and 0% red and 0% green).
    • If the elevation is divisible by 10, color the pixel black (0% red, 0% green, and 0% blue).
    • Otherwise, the pixel should be colored white (100% red, 100% green, and 100% blue).

    A sample run of your program should look like:

    How blue is the ocean:  0.5
    What is the output file:  medBlue.png
    Thank you for using my program!
    Your map is stored medBlue.png.

    Your resulting map should look like:

    and be saved to a file called medBlue.png.

    Note: before submitting your program for grading, remove the commands that show the image (i.e. the ones that pop up the graphics window with the image). The program is graded on a server on the cloud and does not have a graphics window, so, the plt.show() and plt.imshow() commands will give an error. Instead, the files your program produces are compared pixel-by-pixel to the answer to check for correctness.

  26. Due Date: 23 March Reading: Burch's Logic & Circuits & Lab 5

    Build a circuit that has the same behavior as a NOR gate (i.e. for the same inputs, gives identical output) using only AND, OR, and NOT gates.

    Here is the truth table for the nor operator:

    in1 in2 in1 nor in2
    TrueTrueFalse
    FalseTrueFalse
    TrueFalseFalse
    FalseFalseTrue

    Save your expression to a text file. See Lab 5 for the format for submitting logical expressions to Gradescope.

  27. Due Date: 24 March Reading: 10-mins to Pandas, DataCamp Pandas & Lab 6

    Modify the program from Lab 6 that displays the NYC historical population data. Your program should ask the user for the borough, an name for the output file, and then display the fraction of the population that has lived in that borough, over time.

    A sample run of the program:

    Enter borough name:  Queens
    Enter output file name:  qFraction.png
    

    The file qFraction.png:

    Note: before submitting your program for grading, remove the commands that show the image (i.e. the ones that pop up the graphics window with the image). The program is graded on a server on the cloud and does not have a graphics window, so, the plt.show() and plt.imshow() commands will give an error. Instead, the files your program produces are compared pixel-by-pixel to the answer to check for correctness.

  28. Due Date: 25 March Reading: 10-mins to Pandas, DataCamp Pandas & Lab 6

    Write a program that computes the minimum, maximum, average and standard deviation of the population over time for a borough (entered by the user). Your program should assume that the NYC historical population data file, nycHistPop.csv is in the same directory.

    A sample run of your program:

    Enter borough: Staten Island
    Minimum population:  727
    Maximum population:  474558
    Average population:  139814.23076923078
    Standard deviation:  162706.80974594955
    

    and another run:

    Enter borough: Brooklyn
    Minimum population:  2017
    Maximum population:  2738175
    Average population:  1252437.5384615385
    Standard deviation:  1153123.5551968655
    

    Hint: See Lab 6.

  29. Due Date: 26 March Reading: Github Guide & Lab 6

    In Lab 6, you created a github account. Submit a text file with the name of your account. The grading script is expecting a file with the format:

    #Name:  Your name
    #Date:  February 2020
    #Account name for my github account
    
    AccountNameGoesHere
    

    Note: it takes a few minutes for a newly created github account to be visible. If you submit to gradescope and get a message that the account doesn't exist, wait a few minutes and try again.

  30. Due Date: 2 April Reading: Ubuntu Terminal Reference Sheet & Lab 6

    Write an Unix shell script that prints: Hello, Hunter College!!!

    Submit a single text file containing your shell commands. See Lab 6 for details.

  31. Due Date: 3 April Reading: Think CS: Chapter 7.4, Turtle Graphics & Lab 6

    The program, turtleString.py (available at: https://github.com/HunterCSci127/CSci127) takes a string as input and uses that string to control what the turtle draws on the screen (inspired by code.org's graph paper programming). Currently, the program processes the following commands:

    • 'F': moves the turtle forward 50 steps
    • 'L': turns the turtle 90 degrees to the left
    • 'R': turns the turtle 90 degrees to the right
    • '^': lifts the pen
    • 'v': lowers the pen
    • 'r': change turtle color to red
    • 'g': change turtle color to green
    • 'b': change turtle color to blue
    For example, if the user enters the string "FLFLFLFL^FFFvFLFLFLFL", the turtle would move forward and then turn left. It repeats this 4 times, drawing a square. Next, it lifts the pen and move forward 3, puts the pen back down and draw another square.

    Modify this program to allow the user also to specify with the following symbols:

    • 'S': makes the turtle stamp
    • 'D': makes the turtle stamp a dot
    • 'B': moves the turtle backwards 50 steps
    • 'p': change the turtle color to purple

    Hint: See Lecture 4 notes.

  32. Due Date: 6 April Reading: Think CS Section 6.7 & Lab 7

    Write a program, using a function main() that prints "Hello, Python!" to the screen. See Lab 7.

  33. Due Date: 13 April Reading: 10-mins to Pandas, DataCamp Pandas & Lab 7

    Modify the program from Lab 7 that displays shelter population over time to:

    • ask the user to specify the input file,
    • ask the user to specify the output file,
    • make a plot of the fraction of the total population that are single over time from the data in input file, and
    • store the plot in the output file the user specified.

    A sample run of the program:

    Enter name of input file:  DHS_2015_2016.csv
    Enter name of output file:  dhsPlot.png
    

    which produces an output:

    Note: The grading script is expecting that the label (i.e. name of your new column) is "Fraction Single".

  34. Due Date: 14 April Reading: Burch's Logic & Circuits

    Logical gates can be used to do arithmetic on binary numbers. For example, we can write a logical circuit whose output is one more than the inputted number. Our inputs are in1 and in2 and the outputs are stored in out1, out2, and out3.


    (click to launch new window with circuit)

    Here is a table of the inputs and outputs:
    InputsOutputs
    Decimal
    Number
    in1in2Decimal
    Number
    out1out2out3
    000 1001
    101 2010
    210 3011
    311 4100

    Submit a text file (.txt) with each of the outputs on a separate line:

    #Name:  YourNameHere
    #Date:  November 2017
    #Logical expressions for a 4-bit incrementer
    
    out1 = ...
    out2 = ...
    out3 = ...
    
    Where "..." is replaced by your logical expression (see Lab 5).

    Note: here's a quick review of binary numbers.

  35. Due Date: 15 April Reading: 10-mins to Pandas, DataCamp Pandas & Lab 6

    Write a program that, given the 'Stars' dataset will do the following:

    • Ask the user for the name of the input file.
    • Ask the user for the name of the star type.
    • Print the radii of the largest and the smallest star for the given star type.

    Note: To put this in perspective, keep in mind that the radii of the stars are given here as multiples of the Sun's radius! (image credits: space.com)


    A sample run:

    Enter file name:  stars.csv
    Enter the name of the star type:  Hypergiant
    The radius of the largest Hypergiant is 1948.5
    The radius of the smallest Hypergiant is 708.9
    

    Another sample run:

    Enter file name:  stars.csv
    Enter the name of the star type:  Brown Dwarf
    The radius of the largest Brown Dwarf is 0.19
    The radius of the smallest Brown Dwarf  is 0.057
    

    Note: You may assume that input is correct (e.g. only star types found in the data are entered as input)

  36. Due Date: 16 April Reading: 10-mins to Pandas, DataCamp Pandas & Lab 7 & Lab 8

    Write a program that asks the user for a CSV of the NYC OpenData Film Permits:

    • There is a sample file for June 2019 film permits on github.
    Your program should then print out:
    • the total number of permits in the file,
    • the count of permits for each borough, and
    • the five most popular locations (stored in the column: "Parking Held").

    A sample run:

      Enter file name: filmPermitsJune2019.csv
      There were 643 film permits.
      Manhattan        336
      Brooklyn         165
      Queens            70
      Staten Island     42
      Bronx             30
      Name: Borough, dtype: int64
    
    
      The five most popular filming locations were
      WEST   48 STREET between 6 AVENUE and 7 AVENUE                                                                             25
      EAST  140 STREET between LOCUST AVENUE and WALNUT AVENUE,  WALNUT AVENUE between EAST  139 STREET and EAST  140 STREET,
      EAST  139 STREET between WALNUT AVENUE and LOCUST AVENUE                                                                    15
      FROST STREET between DEBEVOISE AVENUE and MORGAN AVENUE,  DEBEVOISE AVENUE between FROST STREET and RICHARDSON STREET       11
      ASHLAND PLACE between LAFAYETTE AVENUE and HANSON PLACE                                                                     10
      EAST   11 STREET between 3 AVENUE and 4 AVENUE,  3 AVENUE between EAST   11 STREET and EAST   12 STREET                      9
      Name: ParkingHeld, dtype: int64
    

    This assignment uses film permit data collected and made publicly by New York City Open Data, and can be found at:

    https://data.cityofnewyork.us/City-Government/Film-Permits/tg4x-b46p.
    Since the files are quite large, use the "Filter" option and a range of dates for "StartDateTime" and "Export" (in CSV format) all permits for those dates.

    Hint: See Lab 7 and Lab 8 for accessing and analyzing structured data.

  37. Due Date: 17 April Reading: Think CS Chapter 7 and Section 9.10 & Lab 4

    Write a program that asks the user for a string, then counts and prints the number of characters that are uppercase letters, lowercase letters, numbers and special characters.

    For this program, you should consider all characters in the ASCII table higher than 31 to be special characters if they are not uppercase letters, lowercase letters or numbers.

    Hint: think about the order in which you check for different type of characters. It is also important to think about what characters should you include in your test strings to ensure that your program always produces the correct output (i.e. catch all edge cases!!!)

    A sample run of the program:

      Please enter a codeword: 4A%5#8sRTq2
      Your codeword contains 3 uppercase letters, 2 lowercase letters, 4 numbers, and 2 special characters.
    

    And another sample run of the program:

      Please enter a codeword: ! 09:@AZ[`az{~
      Your codeword contains 2 uppercase letters, 2 lowercase letters, 2 numbers, and 8 special characters.
    
  38. Due Date: 20 April Reading: Think CS: Chapter 6 & Lab 7

    Fill in the missing function, dayString(), in the program, days.py (available at: https://github.com/HunterCSci127/CSci127). The function should take number between 0 and 7 as a parameter and returns the corresponding day as a string. For example, if the parameter is 1, your function should return "Monday". If the parameter is 2, your function should return out "Tuesday", etc.

    Note: The grading scripts are expecting that your function is called dayString(). You need to use that name, since instead of running the entire program, the scripts are "unit testing" the function-- that is, calling that function, in isolation, with different inputs to verify that it performs correctly.

    Hint: See notes from Lecture 7 and Lab 7.

  39. Due Date: 21 April Reading: Think CS Chapter 6 and Chapters 7, Lab 5 & Lab 7

    Write a function, computePrice(), that takes as two parameters: the age group and the ticket type, and returns the price for admission to the American Museum of Natural History.

    • If the ticket type is "admission" and the age group is "adult", the price is $23.
    • If the ticket type is "admission" and the age group is "child", the price is $13.
    • If the ticket type is "admission" and the age group is "senior", the price is $18.
    • If the ticket type is "+exhibitions" and the age group is "adult", the price is $33.
    • If the ticket type is "+exhibitions" and the age group is "child", the price is $20.
    • If the ticket type is "+exhibitions" and the age group is "senior", the price is $27.
    • If the ticket type or age group are not one of the above, it returns -1.

    A template program, AMNHAdmission.py, is available on the CSci 127 repo on github. The grading script does not run the whole program, but instead tests your function separately ('unit tests') to determine correctness. As such, the name of the function must match exactly (else, the scripts cannot find it).

    A sample run:

      Enter the age group (child, adult, senior): child
      Enter the ticket type (admission / +exhibitions): admission
      The price of your ticket is 13.0
        

    And another:

        Enter the age group (child, adult, senior): senior
        Enter the ticket type (admission / +exhibitions): +exhibitions
        The price of your ticket is 27.0
        

    Hint: See Lab 7.

  40. Due Date: 22 April Reading: Think CS Chapter 6

    Write two functions, triangle() and nestedTriangle(). Both functions take two parameters: a turtle and an edge length. The pseudocode for triangle() is:

            triangle(t, length):
            1.  If length > 10:
            2.     Repeat 3 times:
            3.         Move t, the turtle, forward length steps.
            4.         Turn t left 120 degrees.
            5.     Call triangle with t and length/2.
        

    The pseudocode for nestedTriangle() is very similar:

            nestedTriangle(t, length):
            1.  If length > 10:
            2.     Repeat 3 times:
            3.         Move t, the turtle, forward length steps.
            4.         Turn t left 120 degrees.
            5.         Call nestedTriangle with t and length/2.
        

    A template program, nestingTrianges.py, is available on the CSci 127 repo on github. The grading script does not run the whole program, but instead tests your function separately ('unit tests') to determine correctness. As such, the function names must match exactly (else, the scripts cannot find it). Make sure to use the function names from the github program (it is expecting triangle() and nestedTriangle()).

    A sample run:

        Enter edge length:  160
        

    which would produce:

  41. Due Date: 23 April Reading: 10-mins to Pandas, DataCamp Pandas & Lab 7

    In Lab 7, we worked through a program that displayed the homeless shelter occupancy over time. The same approach can be used for displaying any dataset where the date and time are stored.

    For this program, use the lab as a starting point to display public school attendance from NYC OpenData. If you would like to test your program on other data, you can filter for an individual school by viewing the data and filtering on the school number ("School DBN"). Export the file as CSV and save. There is a sample file for the high school on campus on github

    Modify the program from Lab 7 that displays shelter population over time to:

    • Ask the user to specify the input file,
    • Ask the user to specify the output file,
    • Convert the date column (which is stored as 'YYYYMMDD') to a datetime format recognized by pandas, for example if your dataframe is df, overwrite the 'Date' column to be:
              df["Date"] = pd.to_datetime(df["Date"].apply(str))	
    • Make a plot of the percent of absent students over time from the data in the input file, and
    • Store the plot in the output file the user specified.

    A sample run of the program:

      Enter name of input file:  dailyAttendanceManHunt2018.csv
      Enter name of output file:  manHunt.png
    

    which produces an output:

    Note: The grading script is expecting that the label (i.e. name of your new column) is "% Absent" and the range of values be between a percentage between 0 and 100 (Hint: what do you multiply by to convert a fraction into a percentage?).

  42. Due Date: 24 April Reading: Think CS: Chapters 4 and 6

    Fill in the missing function to animate hurricane data (inspired by the 2018 Nifty Hurricane Program by Phil Ventura).

    Your function, animate(t,lat,lon,wind) takes as input:

    • t: a turtle,
    • lat: an integer storing the current latitude,
    • lon: an integer storing the current longitude, and
    • wind: the current wind speed in miles per hour.

    Your function should move the turtle to the current location (longitude, latitude), and then based on the Saffir-Simpson Hurricane Wind Scale, change the turtle to be:

    • red and pen size 5 for Category 5 (windspeed > 157 mph)
    • orange and pen size 4 for Category 4 (windspeed in 130-156 mph)
    • yellow and pen size 3 for Category 3 (windspeed in 111-129 mph)
    • green and pen size 2 for Category 2 (windspeed in 96-110 mph)
    • blue and pen size 1 for Category 1 (windspeed in 74-95 mph)
    • white and pen size 1 if not hurricane strength

    A template program, hurricane.py, and background image, mapNASA.gif, are available on the CSci 127 repo on github. The grading script does not run the whole program, but instead runs each of your functions separately ('unit tests') to determine correctness. As such, the names of the functions must match exactly the ones listed above (else, the scripts cannot find them).

    Two test files (irma.csv and jose.csv) are from the Nifty site. Additional CSV files are available there.

    Hint: You may find the following turtle commands useful: color(), goto(), and pensize().

  43. Due Date: 27 April Reading: Think CS: Chapter 6 and Section 8.10

    Fill in the missing functions:

    • average(region): Takes a region of an image and returns the average red, green, and blue values across the region.
    • setRegion(region,r,g,b): Takes a region of an image and red, green, and blue values, r, g, b. Sets the region so that all points have red values of r, green values of g, and blue values of b.

    The functions are part of a program that averages smaller and smaller regions of an image until the underlying scene is visible (inspired by the elegant koalas to the max).

    For example, if you inputted our favorite image, you would see (left to right):

    and finally:

    A template program, averageImage.py, is available on the CSci 127 repo on github. The grading script does not run the whole program, but instead runs each of your functions separately ('unit tests') to determine correctness. As such, the names of the functions must match exactly the ones listed above (else, the scripts cannot find them).

    Hint: See notes from Lecture 9.

  44. Due Date: 28 April Reading: Think CS: Chapter 3 & Lab 9

    The program, errorsHex.py, has lots of errors. Fix the errors and submit the modified program.

    Hint: See Lab 9.

  45. Due Date: 29 April Reading: Folium Tutorial & Lab 9

    Write a program that uses folium to make a map of New York City. Your map should be centered at (40.75, -74.125) and include a marker for the main campus of Hunter College. The HTML file your program creates should be called: nycMap.html

    Hint: See Lab 9.

  46. Due Date: 30 April Reading: Folium Tutorial & Lab 9

    Using folium (see Lab 9), write a program that asks the user for the name of a CSV file, name of the output file, and creates a map with markers for all the traffic collisions from the input file.

    A sample run:

    Enter CSV file name:  collisionsThHunterBday.csv
    Enter output file:  thMap.html
    

    which would produce the html file:

    (The demo above is for October 18, 2016 using the time the collision occurred ("TIME") to label each marker and changed the underlying map with the option: tiles="Cartodb Positron" when creating the map.)

    This assignment uses collision data collected and made publicly by New York City Open Data. A sample file, collisionsThHunterBday.csv from 18 October 2016 was downloaded and can be used to test your program.

    Note: when creating datasets to test your program, you will need to filter for both date (to keep the files from being huge) and that there's a location entered. The former is explained above; to check the latter, add the additional filter condition of "LONGITUDE is not blank".

    Hint: For this data set, the names of the columns are "LATITUDE" and "LONGITUDE" (unlike the previous map problem, where the data was stored with "Latitude" and "Longitude").



More to come...

Here's xkcd on the simplicity of Python:

(This file was last modified on 11 November 2019.)