Assignments
-
Final Exam Prep! II
Due: Friday 1/17 10:00am
Submission name: final1.nlogo
Final Exam Information:
- The final exam will be 9:45am Friday, January 24th.
- You will have 1 hour to complete the exam.
- The exam will have 40-50 multiple choice questions.
- The exam will cover the following skills (full grid below):
- 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 21, 22, 23
- When applicable, skills will be assessed in both NetLogo and Racket.
Write sample NetLogo Questions:
Write 4 different multiple choice questions covering the skills on the final exam using NetLogo. Use the following format for each question:
;########## ;MC Question: ;Skill: ;Options: ; ;Answer ; ;########## ;########## ;MC Question: ;Skill: ;Options: ; ;Answer ; ;##########
Here is a filled in Example:
;########## ;MC Question: ;Skill: 9001 ;What is the air speed of an unladen swallow? ;Options: ;A) 2 mph ;B) 20 mph ;C) 200 mph ;D) African or European? ; ;Answer: D ;########## ;########## ;MC Question: ;Skill: 9002 ;Who you gonna call? ;Options: ;A) Transformers ;B) Ghostbusters ;C) Thundercats ;D) Teenage Mutant Ninja Turtles ; ;Answer: B ;##########
-
Final Exam Prep!
Due: Thursday 1/17 10:00am
Submission name: final0.rkt
Final Exam Information:
- The final exam will be 9:45am Friday, January 24th.
- You will have 1 hour to complete the exam.
- The exam will have 40-50 multiple choice questions.
- The exam will cover the following skills (full grid below):
- 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 21, 22, 23
- When applicable, skills will be assessed in both NetLogo and Racket.
Write sample Racket Questions:
Write 4 different multiple choice questions covering the skills on the final exam using Racket. Use the following format for each question:
#lang racket #| MC Question: Skill: Options: Answer |# #|
Here is a filled in Example:
#| MC Question: What is the air speed of an unladen swallow? Skill: 9001 Options: A) 2 mph B) 20 mph C) 200 mph D) African or European? Answer: D |# #| MC Question: Who you gonna call? Skill: 9001 Options: A) Transformers B) Ghostbusters C) Thundercats D) Teenage Mutant Ninja Turtles Answer: B |#
Skill Grid
Skill Minimal Competency Developing Competency Competency Mastery 2. Using Functions Can explain the concept of a function. Uses a single function to produce a desired outcome. Combines multiple functions to produce a desired outcome. Appropriately uses functions that return and do not return values, combining them to produce a desired outcome. 3. Writing functions/procedures. Can write the contract for a function. Can write simple functions given a contract. Can write complex functions given a contract and can write contracts for functions given a specified task. Can write contracts for complex functions, implement those functions and create effective test cases for them. 5. Working with Boolean Values Understands the purpose of boolean values. Demonstrates the appropriate use of comparison operators. Demonstrates the appropriate use of comparison and boolean operators. Writes functions that take in boolean values and/or return boolean values. 6. Using Conditional Statements Can trace the result of a single conditional statement. Can write conditional statements with one or two results. Can write nested conditional statements. Can use at least two different kinds of conditional statements, and understand the benefits of each. 7. Using Randomness in Programs Can use one language provided random function. Can use a random function to generate integers or floating point values in a specified range. Can use random functions to produce random integers and floating point values within specified ranges. Can use random functions with conditional statements to write functions with randomly controlled outcomes. 8. Data Types Demonstrates an understanding of numeric data types. Demonstrates an understanding of numeric and text based data types. Writes programs that work with both numeric and text based data types. Can explain data types that are references to other data. 9. Data Structures Understands the difference between single values and data structures. Can describe how one data structure stores data. Can use a data structure to store multiple values in a program. Can use language provided features to effectively create and access data in a data structure. 10. Recursion Can describe what a recursive function is. Can accurately trace a recursive function. Can write and trace a recursive function. Can develop a recursive solution to a problem and correctly implement it. 11. Iteration Can describe iteration. Can use one built in language structure or feature to write an iterative process. Can use multiple built in language structures/features to write an iterative process. Can control iterative processes using counters and non-counter based boolean conditions. 12. Number Systems Demonstrates understanding of the decimal number system. Demonstrates understanding of the binary number system. Can convert between decimal and binary number systems. Can work in octal and hexadecimal number systems. 13. Digital Representation of Data Demonstrates an understanding of bits and bytes. Demonstrates how bits can be used to represent integers. Demonstrates how bits can be used to represent characters. Demonstrates how bits can be used to represent other kinds of data (e.g. images, audio) 14. Main Components of Computers Can describe and identify one of the 4 main components of computers. Can describe and identify 2 of the 4 main components of computers. Can describe and identify the 4 main components of computers. Can describe how the 4 main components of computers interact with each other. 16. The Internet Can explain the roles of servers, clients and routers. Can explain how computers are addressed on the internet and what domain names are. Can explain how internet traffic flows between devices. Can explain the role of different internet protocols. 18. Agent-based Computing Can explain what an agent is in computing. Can explain the benefits of agents for certain kinds of problems. Can use different agents of the same type in a program. Can effectively combine agents in a complex model. 20. Working with Agent Sets Can work with agent sets that contain all agents of a given type. Can create agent sets that meet a specific criteria. Can create and instruct specific agent sets. Can write a program that provides multiple instructions to multiple different agent sets. 21. Agent Interaction Can have agents interact with other agents of the same type. Can have agents interact with agents of different types. Can write a program with complex agent interaction. Can create sub-types of agents and use them to interact with other agents. 22. Using Variables Recognizes the difference between variables and literals Demonstrates ability to understand code which uses variables Correctly uses variables in programming Correctly uses the appropriate types of variables for different programming algorithms 23. How Functions Operate Knows the difference between calling and defining a function Can correctly define and call functions Understands, in general terms, the difference between what happens in the computer when you define or when you call a function. Can correctly explain what happens in the computer when a function is called and when a function is defined, using the correct vocabulary (ex, parameters/arguments).
-
Work 37: Picture Time Again!
Due: Wednesday 1/14 10:00am
Submission name: work37.nlogo
Like yesterday, you will be using patches in NetLogo to represent images, this time with some other procedures. You should add these to yesterday’s assignment. Recreate the NetLogo program found here: http://homer.stuy.edu/~dw/netlogo/img/images_obf.html
World State:
We want 1 patch to be equal to 1 pixel to do that:
- Set the origin to the bottom-left corner.
- Set the size to 640 x 480 (or whatever the resolution of your source image is)
- Set the patch size to 1
Patch properties
Give patches 2 properties to be used in your procedures:
start_color
next_color
Procedures
horizontal_flip
- Flip the orientation of the image horizontally.
vertical_flip
- Flip the orientation of the image vertically.
mirror
- All the patches on the right half of the image should change color the same way they do for
horizontal_flip
- All the patches on the left half of time image should not change.
edge_detect
- For this, add a new patch property called
color_difference
- Useful background information:
- When given an agentset
of
will return a list of values.- i.e.
[color] of turtles
will return a list of colors (one entry per turtle)
- i.e.
sum
is a NetLogo procedure that will return the sum of the values in a list.
- When given an agentset
- We can determine if a patch represents an edge in our image by comparing its color to the colors of its neighbors. This is called edge detection. One common edge detection algorithm works as follows:
- Grayscale the image (this removes color information but retains shape information of an image)
- Find the average color of the pixels surrounding a given pixel.
- Find the (absolute value) difference between the color of a pixel and the average color of its surrounding pixels.
- If the difference is above a set threshold value, then the pixel must be on an edge, otherwise its not.
- Make all the “edge” pixels one color (i.e. black) and all the non-edge pixels another (i.e. white)
edge_detect
should run the algorithm explained above. Some things to play with:- Different definitions of “surrounding” patches.
- Using a slider for the threshold value.
- Using calculations other than average and difference.
-
Work 37: Picture Time!
Due: Tuesday 1/14 10:00am
Submission name: work37.nlogo
Recreate the NetLogo program found here: http://homer.stuy.edu/~dw/netlogo/img/images_obf.html. Important notes about the web version, all related to the fact that it is slower than regular NetLogo:
- The world size is very small (320x240).
- Most of the procedures will run slowly, do not spam the buttons. Wait until you see a result to try again.
- The
setup
procedure is particularly slow, you will need to us it once, but after that, use thereset
button instead.
World State:
We want 1 patch to be equal to 1 pixel to do that:
- Set the origin to the bottom-left corner.
- Set the size to 640 x 480
- Set the patch size to 1
Patch properties
Give patches 2 properties to be used in your procedures:
start_color
next_color
Procedures
setup
- Clear the world
- Load an image as pcolors using
import-pcolors
. You can use the image at the top of this assignment, or one of your choosing. For best results, pick an image with a resolution of 640x480 pixels. - After all the patches have loaded their
pcolor
values, setstart_color
topcolor
.
reset
- A patch should changes its
pcolor
to itsstart_color
value. - If done correctly,
reset
will be much faster to run thansetup
grayscale
- Change a patches
pcolor
to a value in the black-white range [0, 10). - Think about how NetLogo arranges colors, this can be done in one or two lines of code.
black_white
- Change a patches
pcolor
to eitherblack
orwhite
black
patches should be ones that were on the darker side of the color spectrum whilewhite
patches should be the others.
color_shift
- Give every patch a color within a range defined by the
base_color
slider. - e.g. if
base_color
is40
, all patches should havepcolor
values in the range [40, 50) grayscale
can be a useful starting point.
rainbow
- Split the image into 7 color bands, coloring them similarly to
color_shift
. - Use these NetLogo color values:
red, orange, yellow, green, sky, blue, violet
scroll
- When run once, every patch should become the
pcolor
of the patch on its left. - When run as a forever button, it should look like the image scrolls across the screen.
next_color
should be used here.
-
Lab 05: Ecosystem
Due: Monday 1/13 10:00am
Submission name: New GH Classroom Link
All the instructions for this assignment can be found in README.md after you click the link above to make a new repository.
- Period 9: https://classroom.github.com/a/RbToKB1p
- Period 10: https://classroom.github.com/a/gTes3iAb
Important note: The world is 51x51 with a patch size of 10
Skills Assessed
Skill Minimal Competency Developing Competency Competency Mastery 5. Working with Boolean Values Understands the purpose of boolean values. Demonstrates the appropriate use of comparison operators. Demonstrates the appropriate use of comparison and boolean operators. Writes functions that take in boolean values and/or return boolean values. 6. Using Conditional Statements Can trace the result of a single conditional statement. Can write conditional statements with one or two results. Can write nested conditional statements. Can use at least two different kinds of conditional statements, and understand the benefits of each. 7. Using Randomness in Programs Can use one language provided random function. Can use a random function to generate integers or floating point values in a specified range. Can use random functions to produce random integers and floating point values within specified ranges. Can use random functions with conditional statements to write functions with randomly controlled outcomes. 17. Modeling Systems Can explain what a model is. Can use a computer program model to explain its subject. Can create a program of a simple model. Can create a program of a complex model. 18. Agent-based Computing Can explain what an agent is in computing. Can explain the benefits of agents for certain kinds of problems. Can use different agents of the same type in a program. Can effectively combine agents in a complex model. 19. Graphical Program Design Can control the basic geometry of a graphical program. Can create programs with purposeful graphical elements. Can create interface elements to control a graphical program. Can create a program with complex graphic components, including interface elements to control the program and provide data about the program as it runs. 20. Working with Agent Sets Can work with agent sets that contain all agents of a given type. Can create agent sets that meet a specific criteria. Can create and instruct specific agent sets. Can write a program that provides multiple instructions to multiple different agent sets. 21. Agent Interaction Can have agents interact with other agents of the same type. Can have agents interact with agents of different types. Can write a program with complex agent interaction. Can create sub-types of agents and use them to interact with other agents.
-
Work 36: Pushy Turtles
Due: Thursday 1/09 10:00am
Submission name: work36.nlogo
Recreate the NetLogo program found here: http://homer.stuy.edu/~dw/netlogo/work36_obf.html. Use the following
setup
procedure:to setup ca crt 1 [ set color yellow ] crt 2000 [ set color orange setxy random-xcor random-ycor ] end
Each
push
procedure asks turtle 0 to wiggle, then check for other turtles. If there are other turtles, turtle 0 will “push” (ask them to move forward 10) them and ask them to turn green.push0
usesturtles-here
push1
usesin-radius
along with theradius
slider.push2
usesin-cone
with theradius
anddegrees
sliders.
-
Lab 04: That's Life
Due: Wednesday 1/08 10:00am
Submission name: New GH Classroom Link
All the instructions for this assignment can be found in README.md after you click the link above to make a new repository.
- Period 9: https://classroom.github.com/a/5-4emSN2
- Period 10: https://classroom.github.com/a/FMNNY37w
Skills Assessed
Skill Minimal Competency Developing Competency Competency Mastery 5. Working with Boolean Values Understands the purpose of boolean values. Demonstrates the appropriate use of comparison operators. Demonstrates the appropriate use of comparison and boolean operators. Writes functions that take in boolean values and/or return boolean values. 6. Using Conditional Statements Can trace the result of a single conditional statement. Can write conditional statements with one or two results. Can write nested conditional statements. Can use at least two different kinds of conditional statements, and understand the benefits of each. 17. Modeling Systems Can explain what a model is. Can use a computer program model to explain its subject. Can create a program of a simple model. Can create a program of a complex model. 18. Agent-based Computing Can explain what an agent is in computing. Can explain the benefits of agents for certain kinds of problems. Can use different agents of the same type in a program. Can effectively combine agents in a complex model. 19. Graphical Program Design Can control the basic geometry of a graphical program. Can create programs with purposeful graphical elements. Can create interface elements to control a graphical program. Can create a program with complex graphic components, including interface elements to control the program and provide data about the program as it runs. 20. Working with Agent Sets Can work with agent sets that contain all agents of a given type. Can create agent sets that meet a specific criteria. Can create and instruct specific agent sets. Can write a program that provides multiple instructions to multiple different agent sets.
-
Work 35: Color Swapping
Due: Friday 1/03 10:00am
Submission name: work35.nlogo
Write a NetLogo program like this:
- Example: http://homer.stuy.edu/~dw/netlogo/work35_obf.html
- This program will use some procedures related to work32, you can find solutions in thesource repository.
Interface
- colors: slider, [1, 14]
- neighborsOnly: switch
- Plot showing how many patches are of each true NetLogo colors.
setup
- Clears the screen.
- Resets ticks (
reset-ticks
) - Make every patch one of the true NetLogo colors (based of colors slider), with as equal distribution as possible. If there are any patches left out of the distribution, have them pick one of the possible colors at random.
tick
colorSwap
- This should be an observer procedure.
- Wait a short amount of time.
- Have every patch change their color to the color of a different randomly selected patch.
- If
neighborsOnly
is on, then the color should be chosen from a randomly selected neighbor. tick
one-of AGENTSET
is similar ton-of N AGENTSET
with one useful exception for this problem:- It always returns one agent instead of an agentset.
-
Work 34: Test Prep, Part V
Due: Friday 12/19 10:00am
Submission name: work34.txt
You can find all the submitted test questions here: https://github.com/mks21-dw/thesource/tree/main/netlogo/test04
Pick 4 of the questions to complete. At the beginning of each function you write, include the question number above as a comment.
You are encouraged to work on more problems to prepare for the exam. You should also take a look at the multiple choice questions. I have not vetted all the questions, so there may be mistakes.
-
Test Prep 04: Questioning
Due: Thursday 12/19 10:00am
Submission name: test04.nlogo
Write Possible Test Questions
Write three potential test questions.
- The first two should be multiple choice questions with 4 options.
- The third one should be a programming question.
Put both questions, and the answers in a plain text file. Use this format:
;########## ;MC Question: ;Skill: ;Options: ; ;Answer ; ;########## ;########## ;MC Question: ;Skill: ;Options: ; ;Answer ; ;########## ;########## ;Programming question: ;Skill: ;Description ; ;Possible solution: ; ;##########
Here is a filled in Example:
;########## ;MC Question: ;Skill: 9001 ;What is the air speed of an unladen swallow? ;Options: ;A) 2 mph ;B) 20 mph ;C) 200 mph ;D) African or European? ; ;Answer: D ;########## ;########## ;MC Question: ;Skill: 9002 ;Who you gonna call? ;Options: ;A) Transformers ;B) Ghostbusters ;C) Thundercats ;D) Teenage Mutant Ninja Turtles ; ;Answer: B ;########## ;########## ;Programming question: ;Write a procedure that will clear the ;screen and create 10 turtles. ;Skill: 17, 18 ;Possible solution: ;########## to setup ca crt 10 end
Test Skills
Skill Minimal Competency Developing Competency Competency Mastery 5. Working with Boolean Values Understands the purpose of boolean values. Demonstrates the appropriate use of comparison operators. Demonstrates the appropriate use of comparison and boolean operators. Writes functions that take in boolean values and/or return boolean values. 6. Using Conditional Statements Can trace the result of a single conditional statement. Can write conditional statements with one or two results. Can write nested conditional statements. Can use at least two different kinds of conditional statements, and understand the benefits of each. 7. Using Randomness in Programs Can use one language provided random function. Can use a random function to generate integers or floating point values in a specified range. Can use random functions to produce random integers and floating point values within specified ranges. Can use random functions with conditional statements to write functions with randomly controlled outcomes. 18. Agent-based Computing Can explain what an agent is in computing. Can explain the benefits of agents for certain kinds of problems. Can use different agents of the same type in a program. Can effectively combine agents in a complex model. 19. Graphical Program Design Can control the basic geometry of a graphical program. Can create programs with purposeful graphical elements. Can create interface elements to control a graphical program. Can create a program with complex graphic components, including interface elements to control the program and provide data about the program as it runs. 20. Working with Agent Sets Can work with agent sets that contain all agents of a given type. Can create agent sets that meet a specific criteria. Can create and instruct specific agent sets. Can write a program that provides multiple instructions to multiple different agent sets. 22. Using Variables Recognizes the difference between variables and literals Demonstrates ability to understand code which uses variables Correctly uses variables in programming Correctly uses the appropriate types of variables for different programming algorithms
-
Work 33: Getting to Know your Neighbors
Due: Wednesday 12/18 10:00am
Submission name: work33.nlogo
Write a NetLogo program like this:
patchRow
- All patches with
pxcor
of-1
should be given a random color. - All other patches with negative
pxcor
values should be the same color as the patch at (-1,pycor
). - All the patches with positive
pxcor
values should have the color of the patch on the opposite side (in both x and y).- i.e. patch 5 10 should have the same color as patch -5 -10
setup
- Clears the screen.
- Creates 1 turtle.
- If the
randomBG
switch istrue
, have all the patches become the same randomly chosen color (out of all possible NetLogo colors).
go
- Have a turtle move around randomly. As it moves, its neighboring patches should change color. At any given time, only the neighboring patches should be different from the rest of the patches.
- Assume this procedure runs in a world where all patches start out the same color.
- Use
wait
to slow down movement.
- All patches with
-
Work 32: Equally Random
Due: Tuesday 12/17 10:00am
Submission name: work32.nlogo
Write a NetLogo program with the following Features:
Example: http://homer.stuy.edu/~dw/netlogo/work32_obf.html
- Interface
- A slider called
numColors
- Should start at 1 and go to 14
- Monitors to show the number of patches for each true NetLogo color.
- Include buttons for each procedure listed below
- A slider called
- Procedures
setup
: observer- Have every patch set its color to a random color.
- The number of colors should be based on the
numColors
slider. - The possible colors should be the “true” NetLogo colors (i.e. 5, 15, 25, …).
setupEqual3
: observer- Have every patch set its color to either
gray
,red
ororange
. - The colors should be randomly chosen, but there should be exactly the same number of patches for each color.
- Have every patch set its color to either
setupEqual
: observer- Have every patch set its color to a random color.
- The number of colors should be based on the
numColors
slider. - The possible colors should be the “true” NetLogo colors (i.e. 5, 15, 25, …).
- The colors should be randomly chosen, but there should be exactly the same number of patches for each color (if the number of colors does not evenly divide the number of patches, then any leftover patches should be black).
- Interface
-
Lab 03: NetLogo
Due: Monday 12/16 10:00am
Submission name: New GH Classroom Link
All the instructions for this assignment can be found in README.md after you click the link above to make a new repository.
- Period 9: https://classroom.github.com/a/wV0FImAx
- Period 10: https://classroom.github.com/a/bOu3-hdO
IMPORTANT NOTE:
- If you see it in your code block of README.md, you can ignore
diagonal
. - It seems that some of you do not have instructions for the last 2 procedures,
patchGradientColor
andpatchColorGradientColor
. You need to write these procedures, see below for the instructions.
;========================================= ; patchColorGradientGraycale ; set every patches color such that the left-most patch ; in a row is black, the right-most in a row ; is almost white (it may not be exactly 9.9), ; and all the patches in between are a grayscale value ; creating a smooth gradient from black to (almost) white ; each row of patches should look the same. to patchGradientGrayscale end ;========================================= ; patchColorGradientColor ; set patches colors similar to patchGradientGrayscale, ; but each row should correspond to a true netlogo color. ; The bottom row should be gray, the next row should be red, ; and so on. The cycle of colors should repeat as needed. to patchGradientColor end
Skills Assessed
Skill Minimal Competency Developing Competency Competency Mastery 5. Working with Boolean Values Understands the purpose of boolean values. Demonstrates the appropriate use of comparison operators. Demonstrates the appropriate use of comparison and boolean operators. Writes functions that take in boolean values and/or return boolean values. 6. Using Conditional Statements Can trace the result of a single conditional statement. Can write conditional statements with one or two results. Can write nested conditional statements. Can use at least two different kinds of conditional statements, and understand the benefits of each. 18. Agent-based Computing Can explain what an agent is in computing. Can explain the benefits of agents for certain kinds of problems. Can use different agents of the same type in a program. Can effectively combine agents in a complex model. 19. Graphical Program Design Can control the basic geometry of a graphical program. Can create programs with purposeful graphical elements. Can create interface elements to control a graphical program. Can create a program with complex graphic components, including interface elements to control the program and provide data about the program as it runs.
-
Work 31: Equally Random
Due: Thursday 12/12 10:00am
Submission name: work31.nlogo
Patch Patterns!
Write a NetLogo program with the following Features:
Example: http://homer.stuy.edu/~dw/netlogo/work31_obf.html
- Interface
- A slider called
numColors
: [1, 14] - A slider called
angle
: [0, 360] - Include buttons for each procedure listed below, pass the appropriate slider value when required.
- A slider called
- Procedures
setup
: observer- Clear the screen and create 1 turtle, the turtle should have its pen down
randomColors [r]
: patch- Have every patch set its color to a random color.
- The number of colors should be based on the
numColors
slider. - The possible colors should be the “true” NetLogo colors (i.e. 5, 15, 25, …).
wiggle0 [theta]
: turtlewait
0.1 of a second- Makes a turtle move forward 1 unit
- Makes a turtle turn right a random number of degrees in the range [0, theta).
wiggle1 [theta]
: turtlewait
0.1 of a second- Makes a turtle move forward 1 unit
- Makes a turtle turn right a random number of degrees in the range [0, theta/2).
- Makes a turtle turn left a random number of degrees in the range [0, theta/2).
wiggle2 [theta]
: turtlewait
0.1 of a second- Makes a turtle move forward 1 unit
- Makes a turtle turn right a random number of degrees in the range [-theta/2, theta/2).
- Interface
-
Work 30: A Patch of Color!
Due: Wednesday 12/11 10:00am
Submission name: work30.nlogo
Patch Patterns!
Recreate this netlogo program.
- There are 4 procedure, each corresponds to a button of the same name.
- The
box
procedure uses theboxEdge
slider. The slider should determine the edge of the red box (for both x and y, positive and negative). In the example image, edge is set to 7. - For all of these functions you only need:
- Arithmetic operators (
+ - * / mod
) - Comparison operators (
> < >= <= = !=
) - Boolean opertors (
and or not
) if
,ifelse
,set
- Arithmetic operators (
- You may use other colors if you find my color selections objectionable.
-
Work 29: Turtle Power!
Due: Tuesday 12/10 10:00am
Submission name: work29.nlogo
Write a NetLogo program with the following Features:
- Interface
- A slider called
num_sides
- Should start at 3 and go to a reasonable number (like 20)
- A slider called
side_length
- Should start at 1 and go to a reasonable number
- A slider called
pattern_angle
- Should start at 0 and go to 360
- For each slider, set the initial value to be something that makes sense, play around with the values to see what works well
- Include buttons for each procedure listed below, pass the sliders as arguments when making the buttons.
- A slider called
- Procedures
setup [n]
: observer- Clear the screen and make
n
turtles (you can add custom features to the turtle if you wish)
- Clear the screen and make
regulargon [n s]
: turtle- Draw a regular polygon with
n
sides of lengths
- Draw a regular polygon with
pattern [n s angle]
: turtle- Call
regulargon
and then turn right byangle
degrees. - Make the button for
pattern
a forever button!
- Call
turtle_spread
: turtle- Have the turtle point up.
- Set the turtle’s x coordinate to 0
- Set the turtle’s y coordinate such that:
- turtle 0 is at the bottom of the world (-16)
- All other turtles are evenly spaced along the y-axis. This will depend on how many turtles there are.
- Interface
-
Work 28: Test Prep, Part IV
Due: Friday 12/6 10:00am
Submission name: work28.txt
You can find all the submitted test questions here: https://github.com/mks21-dw/thesource/tree/main/test03
Pick 4 of the questions to complete. At the beginning of each function you write, include the question number above as a comment.
You are encouraged to work on more problems to prepare for the exam. You should also take a look at the multiple choice questions. I have not vetted all the questions, so there may be mistakes.
-
Test Prep 03: Questioning
Due: Thursday 12/05 10:00am
Submission name: test03.txt
Write Possible Test Questions
Write three potential test questions.
- The first two should be multiple choice questions with 4 options.
- The third one should be a more open-ended question.
- It could be something like base conversion, encoding-based, definition, short explanation etc (nothing too long).
Put both questions, and the answers in a plain text file. Use this format:
#| MC Question: Skill: Options: Answer |# #| MC Question: Options: Skill: Answer |# #| Open Ended Question: Skill: Description Possible solution: |# ANSWER GOES HERE
Here is a filled in Example:
#| MC Question: What is the air speed of an unladen swallow? Skill: 9001 Options: A) 2 mph B) 20 mph C) 200 mph D) African or European? Answer: D |# #| MC Question: Who you gonna call? Skill: 9001 Options: A) Transformers B) Ghostbusters C) Thundercats D) Teenage Mutant Ninja Turtles Answer: B |# #| Open Ended Question: Skill: 9002 What is 1 in binary? Possible solution: |# 1
Test Skills
Skill Minimal Competency Developing Competency Competency Mastery 12. Number Systems Demonstrates understanding of the decimal number system. Demonstrates understanding of the binary number system. Can convert between decimal and binary number systems. Can work in octal and hexadecimal number systems. 13. Digital Representation of Data Demonstrates an understanding of bits and bytes. Demonstrates how bits can be used to represent integers. Demonstrates how bits can be used to represent characters. Demonstrates how bits can be used to represent other kinds of data (e.g. images, audio) 14. Main Components of Computers Can describe and identify one of the 4 main components of computers. Can describe and identify 2 of the 4 main components of computers. Can describe and identify the 4 main components of computers. Can describe how the 4 main components of computers interact with each other. 16. The Internet Can explain the roles of servers, clients and routers. Can explain how computers are addressed on the internet and what domain names are. Can explain how internet traffic flows between devices. Can explain the role of different internet protocols.
-
Work 24: Turtle Power!
Due: Wednesday 12/04 10:00am
Submission name: work27.nlogo
Write the following NetLogo procedures:
setup
- Clears the screen.
- Creates 1 turtle facing up. (you may set other properties if you like)
regulargon [n s]
- Instructs a turtle to draw a regular polygon with
n
sides where each side iss
steps in length. - You should look into the
repeat
command, either on the online book or the netlogo dictionary
- Instructs a turtle to draw a regular polygon with
Make sure to test these procedures.
-
Work 26: Get NetLogo
Due: Tuesday 12/03 10:00 am
Submission name: work26.txt
Learn NetLogo
To get started with NetLogo, read the following 2 chapters in the online book:
After reading, answer the following questions in a plain text document:
- What are NetLogo agents? What are the differences between the Observer, Patches and Turtles?
- What is a property? Where can we find the properties of an agent?
- How does the NetLogo color system work?
- What command would set every patch to a random color (out of all possible colors)?
- What command would set every patch to either red or orange?
- What command would set every turtle at a random positive x-coordinate and a random negative y-coordinate.
Download NetLogo!
- If you haven’t done so already.
- You can find NetLogo here: http://ccl.northwestern.edu/netlogo/download.shtml
- If that link doesn’t work, try this: https://ccl.northwestern.edu/netlogo/6.4.0/
- The current version is 6.4.0
- When you run NetLogo, make sure you open the program called NetLogo 6.4.0. There will be other installed programs in the same location.
-
Project 00:
Due: Friday 12/06 10:00 am
Submission name: p00.pdf
Overview
Below you will find 2 tasks that will require you to create both text and diagrams. You can write and draw these things in any way you see fit. You will submit a single pdf file that contains all of these pieces. Each part should be a separate page, resulting in 5 pages total.
The Internet (2 pages)
You open a web browser, type
http://homer.stuy.edu
into the address bar, and hit enter. In a matter of seconds, a web page is rendered in your browser. How did that happen?Your mission
Provide as much detail as possible in explaining this process. Your explanation should consist of 2 parts:
- An ordered list of steps explaining how the request and subsequent response was transmitted. If the steps involve an protocols and/or addresses, explain those.
- A diagram showing how that traffic flowed between your computer and homer. The diagram should show:
- Your computer (at home).
- Any network device inside your home (router, access point, etc. Not other computers/phones/gaming systems/refrigerators).
- Your ISP
- Stuyvesant’s ISP - Spectrum
- Stuyvesant’s Gateway Router
- Homer (homer is connected to the gateway router via a switch)
Computer Data & Components (3 pages)
You are working on an assignment in DrRacket, you type the following line of code:
(define foo 42)
You save the file. What happened?
Your mission
Provide as much detail as possible in explaining this process. Your explanation should consist of 3 parts:
- An ordered list of steps explaining how the text of the file was entered into the computer, where that data was being kept before saving, and what happened to the data when you saved the file.
- A diagram showing the computer components you mentioned in part 1 and how the data flowed between them.
- Using a standard encoding scheme, provide the digital representation of the file, using hexadecimal values.
Skill Minimal Competency Developing Competency Competency Mastery 12. Number Systems Demonstrates understanding of the decimal number system. Demonstrates understanding of the binary number system. Can convert between decimal and binary number systems. Can work in octal and hexadecimal number systems. 13. Digital Representation of Data Demonstrates an understanding of bits and bytes. Demonstrates how bits can be used to represent integers. Demonstrates how bits can be used to represent characters. Demonstrates how bits can be used to represent other kinds of data (e.g. images, audio) 14. Main Components of Computers Can describe and identify one of the 4 main components of computers. Can describe and identify 2 of the 4 main components of computers. Can describe and identify the 4 main components of computers. Can describe how the 4 main components of computers interact with each other. 16. The Internet Can explain the roles of servers, clients and routers. Can explain how computers are addressed on the internet and what domain names are. Can explain how internet traffic flows between devices. Can explain the role of different internet protocols.
-
Work 21: Computer Components
Due: Monday 11/25 10:00 am
Submission name: work25.txt
There are many different kinds of computer hardware out there, but most computers contain these five components:
- Processor (CPU)
- Storage
- Memory
- Input
- Output
Use whatever resources are at your disposal to answer the following for the first three components listed (processor, storage, memory):
- What does this component do?
- How are bits saved and/or transmitted by this component?
- How does this component interact with the other two?
- What general order of magnitude (kilo, mega, giga, terra) of bytes do we use to describe the speed of this component (consider normal versions available to the average person)?
- What general order of magnitude (kilo, mega, giga, terra) of bytes do we use to describe the amount of data stored by this component (consider normal versions available to the average person)?
- Provide a distinct concrete example of this component.
-
Work 24: 6583677373
Due: Thursday 11/21 10:00 am
Submission name: work24.txt
Text encoding
- All digital data is represented as binary numbers.
- For text, each character is assigned a number according to some agreed upon convention, called an encoding.
- ASCII was the standard for many years.
- In a plain text file:
- write your first name in lowercase letters
- Write your name is ASCII, put a space between each number
- Convert your ASCII name to hexadecimal, using one 2 digit hexadecimal number for each letter. Put spaces between each number.
- Convert your hexadecimal name to binary, remember that each hex digit turns into 4 binary digits. Your file may look like this:
jonalf 106 111 110 97 108 102 6a 6f 6e 61 6c 66 0110 1001 0110 1111 0110 1110 0110 0001 0110 1100 0110 0110
- If you are using a computer at school, you could try looking at the file in the terminal using
$ hexdump -C work20.txt
Image encoding
- Images are often represented as a grid of color values for pixels, where each pixel is given separate values for Red, Green, and Blue (in that order).
- Here is all the color information for a very small (5x5 pixel) image:
FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00
- Describe what these numbers represent, as well as what the image looks like.
Emojis!
- In order to handle more potential characters that ASCII’s measly 128, we have a new standard, Unicode!
- You can get unicode information for any character here: https://symbl.cc/en/emoji/
- When you click on an emoji, you can see it’s technical information and encoding. For example:
- 😀 https://symbl.cc/en/1F600/
- Name: Grinning Face
- Unicode number: U+1F600
- UTF-8 Value in hex: F0 9F 98 80
- Number of Bytes used to encode: 4B (hint: look at the binary representation, how many bits does it need?).
- Pick a letter in the english alphabet, and provide the following information:
- letter
- Unicode number
- UTF-8 value
- Number of bytes used to encode the letter
- Pick an emoji (keep it clean), and provide the following information:
- emoji name
- Unicode number
- UTF-8 value
- Number of bytes used to encode the emoji
- Here is some further information on unicode, it’s a bit technical, but describes how it works in more detail: https://blog.daftcode.pl/unicode-details-for-developers-300dc6f6e11e.
-
Work 23: So Basic
Due: Wednesday 11/20 10:00am
Submission name: work23.txt
Write your answers to the following questions in a plain text file (with a .txt extension). If you are not certain how to create a plain text file here are some suggestions:
Here are the questions, you could google them, but you can also answer them with the main principles of different base arithmetic we’ve discussed in class, notably:
- The digits in any base are 0 -> (base - 1).
- We use letters if the base is greater than 10.
- Each digit in a number represents that digit times a power of the base (starting at the 0 power going right to left).
Questions:
- What is the largest 8 digit binary number?
- What is the smallest 9 digit binary number?
- What is the decimal value of the largest 8 digit binary number?
- What is the largest 3 digit hexadecimal number?
- What is the smallest 4 digit hexadecimal number?
- What is the decimal value of the largest 3 digit hexadecimal number?
- What is the largest 1 digit hexadecimal number?
- What is the largest 1 digit hexadecimal number in binary?
- How many bits would you need to represent a 1 digit hexadecimal number?
- What would the binary representation of the third digit of the hexadecimal number DEAD16
- A (bad) computer science joke goes something like this:
There are 10 types of people in the world; Those that understand binary, and those that don’t.
- Explain the joke.
- (bonus round) Another computer science joke:
Why do computer programmers celebrate Christmas on Halloween? Because Oct31 = Dec25
- (bonus round) Another computer science joke:
- Explain the joke (half of it is decimal, the other half is a different base, neither binary nor hexadecimal).
-
Work 22: Identity Crisis
Due: Monday 11/18 10:00am
Submission name: work22.txt
]
What does google know about me?
- Look at your google data summary (how-to) using your stuy.edu address and a gmail address (if you have one).
- Specific things to focus on
- Web & App Activity
- Location History
- Ad Personalization
- Activity and Timeline
- Specific things to focus on
- Answer the following questions in a plain text file.
- Have you looked at your Google data & activity before?
- Have you changed any of the activity tracking settings before?
- Did you change any of these settings after looking up your data?
- Were you surprised by anything you found? If so, what?
- Do you believe that the amount of data google keeps on you is reasonable?
How unique is my browser?
- Go to panopticlick and click “TEST ME”
- When it is done, click on “Show full results for fingerprinting”
- Take note of the information available.
- Run the same test in a Private Browser window for the same browser.
- Do this again in a different browser, once normal and once private.
- In the same text file as above, answer: Did the tests produce different results? If so, how different were they?
- Look at your google data summary (how-to) using your stuy.edu address and a gmail address (if you have one).
-
Work 21: Getting Connected
Due: Thursday 11/14 10:00am
Submission name: work21.txt
Answer the following questions
- What is your Internet Service Provider (ISP)
- What is your internal IP address?
- If you are concerned about privacy, you may only provide the first two sections of your IP address if you prefer, and * in the last two sections. This would look something like:
149.89.*.*
- If you are concerned about privacy, you may only provide the first two sections of your IP address if you prefer, and * in the last two sections. This would look something like:
- What is your external IP address?
- As before, you can leave out the last two sections if you like.
- What is your computer’s MAC/Hardware address?
- You may only provide the first three sections of your MAC address if you prefer, and * in the last few. This would look something like:
92:1f:ea:*:*:*
- You may only provide the first three sections of your MAC address if you prefer, and * in the last few. This would look something like:
- What is the IP address of the DNS server your computer uses?
- Run a speedtest in a browser on your computer 3 times, what were your download and upload results? What was the average?
- What is the usual number of devices that could be connected to the internet in your home at the same time? How are they connected?
-
Work 20: Get the Net
Due: Wednesday 11/13 10:00am
Submission name: work20.txt
- Read the following article: https://www.vox.com/cards/the-internet/
- Watch the following video (3.5 minutes, you can do it): https://www.youtube.com/watch?v=ewrBalT_eBM
- Write your answers to the following questions in a plain text file (with a
.txt
extension). If you are not certain how to create a plain text file here are some suggestions:- On a Windows computer, use Notepad.
- On a mac computer, use TextEdit, make sure to select “Make Plain Text” from the Format menu.
- You can also directly create and write the file on GitHub by selecting “Create new file” under “Add file”.
- Answer these questions
- What is an I.P. Address?
- Why is Tim Breners-Lee important?
- What is the last mile?
- What does the lock next to a url signify?
- What is the IETF, what does it do?
- What is ICANN, what does it do?
- What is a packet?
- Why are websites broken up and transmitted in small pieces?
-
Work 19: Test Prep, Part III
Due: Friday 11/8 10:00am
Submission name: work19.rkt
You can find all the submitted test questions here: https://github.com/mks21-dw/thesource/tree/main/racket/test02
Pick 4 of the programming questions to complete. At the beginning of each function you write, include the question number above as a comment. Be sure to include test cases with your program.
You are encouraged to work on more problems to prepare for the exam. You should also take a look at the multiple choice questions. I have not vetted all the questions, so there may be mistakes.
-
Test Prep 02: Questioning
Due: Thursday 10/07 10:00am
Submission name: test02.rkt
Write Possible Test Questions
With your TableBuddy™ write three potential test questions.
- The first two should be multiple choice questions with 4 options.
- The third one should be a function to program.
- This should be similar to the programming work you have had so far. Include all the information needed to write the function (formulas, etc).
Put both questions, and the answers in a racket file. You are working with your TableBuddy™, but if you dont finish in class you can both submit different files from home. You can put multiple lines together in a single comment using
#| .... |#
. Use this format:#lang racket #| MC Question: Skill: Options: Answer |# #| MC Question: Options: Skill: Answer |# #| Programming question: Skill: Description Possible solution: |# CODE GOES HERE
Here is a filled in Example:
#| MC Question: What is the air speed of an unladen swallow? Skill: 9001 Options: A) 2 mph B) 20 mph C) 200 mph D) African or European? Answer: D |# #| MC Question: Who you gonna call? Skill: 9001 Options: A) Transformers B) Ghostbusters C) Thundercats D) Teenage Mutant Ninja Turtles Answer: B |# #| Programming question: Skill: 2,3 Write a function that takes the radius of a circle and returns it's area. area = pi * r^2 Possible solution: |# (define areaC (lambda (radius) (* pi radius radius))) (areaC 10)
Test Skills
Skill Minimal Competency Developing Competency Competency Mastery 2. Using Functions Can explain the concept of a function. Uses a single function to produce a desired outcome. Combines multiple functions to produce a desired outcome. Appropriately uses functions that return and do not return values, combining them to produce a desired outcome. 3. Writing functions/procedures. Can write the contract for a function. Can write simple functions given a contract. Can write complex functions given a contract and can write contracts for functions given a specified task. Can write contracts for complex functions, implement those functions and create effective test cases for them. 4. Understanding Algorithms Can follow an algorithm to produce a desired outcome. Can break down a simple problem into basic steps that will result in a desired outcome. Can break down a problem into basic steps and implement those steps in code. Can analyze the differences between 2 or more algorithms that produce the same desired outcome. 5. Working with Boolean Values Understands the purpose of boolean values. Demonstrates the appropriate use of comparison operators. Demonstrates the appropriate use of comparison and boolean operators. Writes functions that take in boolean values and/or return boolean values. 6. Using Conditional Statements Can trace the result of a single conditional statement. Can write conditional statements with one or two results. Can write nested conditional statements. Can use at least two different kinds of conditional statements, and understand the benefits of each. 9. Data Structures Understands the difference between single values and data structures. Can describe how one data structure stores data. Can use a data structure to store multiple values in a program. Can use language provided features to effectively create and access data in a data structure. 10. Recursion Can describe what a recursive function is. Can accurately trace a recursive function. Can write and trace a recursive function. Can develop a recursive solution to a problem and correctly implement it. 22. Using Variables Recognizes the difference between variables and literals Demonstrates ability to understand code which uses variables Correctly uses variables in programming Correctly uses the appropriate types of variables for different programming algorithms 23. How Functions Operate Knows the difference between calling and defining a function Can correctly define and call functions Understands, in general terms, the difference between what happens in the computer when you define or when you call a function. Can correctly explain what happens in the computer when a function is called and when a function is defined, using the correct vocabulary (ex, parameters/arguments).
-
Work 18: A Little Wordy Told Me
Due: Wednesday 11/06 10:00am
Submission name: work18.rkt
Setup
- First, download the sentence.rkt
- You will need 3 plain text files, call them
nouns.txt
,verbs.txt
,adjectives.txt
. Put the correct kinds of words in those files, one word per line.
Better sentences
- Sometimes, we put articles like “the” or “a” in front of a noun (or wordy-noun). Modify
noun-phrase
so that there is a 50% chance of either:- Returning a “wordy-noun”.
- Adding an article to the beginning of a “wordy-noun” list.
- A simple sentence contains a subject (in this case a noun-phrase) and a verb, eg “the cat eats”. Sometimes it’s nice to add an object after the verb, eg “the cat eats a fish”. Modify
verb-phrase
so that there is a 50% chance of either:- Returning a list with verb in it.
- Returning a list with a verb followed by a
noun-phrase
. - To get this working, you’ll need to use th
append
function we discussed today in class. There is also an example ofappend
in thesentence
function.
Better-er sentences
- Make sure each txt file has at least 10 words.
- Currently,
wordy-noun
,noun-phrase
andverb-phrase
each have a 50% chance of returning one of the two options available. What would you modify to change this split. Try to create some of these possibilities:- 25% / 75%
- 40% / 60%
- 37% / 63%
-
Lab 02: See: Recursion
Due: Monday 11/04 10:00am
Submission name: New GH Classroom Link
All the instructions for this assignment can be found in README.md after you click the link above to make a new repository.
- Period 9: https://classroom.github.com/a/BMy06WKe
- Period 10: https://classroom.github.com/a/ZGb-7Etv
Reminder: Test next Friday, 11/08
Skills Assessed
Skill Minimal Competency Developing Competency Competency Mastery 2. Using Functions Can explain the concept of a function. Uses a single function to produce a desired outcome. Combines multiple functions to produce a desired outcome. Appropriately uses functions that return and do not return values, combining them to produce a desired outcome. 3. Writing functions/procedures. Can write the contract for a function. Can write simple functions given a contract. Can write complex functions given a contract and can write contracts for functions given a specified task. Can write contracts for complex functions, implement those functions and create effective test cases for them. 4. Understanding Algorithms Can follow an algorithm to produce a desired outcome. Can break down a simple problem into basic steps that will result in a desired outcome. Can break down a problem into basic steps and implement those steps in code. Can analyze the differences between 2 or more algorithms that produce the same desired outcome. 5. Working with Boolean Values Understands the purpose of boolean values. Demonstrates the appropriate use of comparison operators. Demonstrates the appropriate use of comparison and boolean operators. Writes functions that take in boolean values and/or return boolean values. 6. Using Conditional Statements Can trace the result of a single conditional statement. Can write conditional statements with one or two results. Can write nested conditional statements. Can use at least two different kinds of conditional statements, and understand the benefits of each. 9. Data Structures Understands the difference between single values and data structures. Can describe how one data structure stores data. Can use a data structure to store multiple values in a program. Can use language provided features to effectively create and access data in a data structure. 10. Recursion Can describe what a recursive function is. Can accurately trace a recursive function. Can write and trace a recursive function. Can develop a recursive solution to a problem and correctly implement it. 22. Using Variables Recognizes the difference between variables and literals Demonstrates ability to understand code which uses variables Correctly uses variables in programming Correctly uses the appropriate types of variables for different programming algorithms
-
Work 17: Recursion
Due: Monday 10/28 10:00am
Submission name: work17.rkt
Write the following functions using recursion. The only list-specific functions you should use are
first
,rest
,list
,null?
, andcons
. Include multiple test cases for each function.(count value g)
- Assume
g
is a list of numbers andvalue
is a number. - Returns the number of times
value
appears ing
.
- Assume
(listMin g currentMin)
- Assume
g
is a list of numbers andcurrentMin
is a number. - Returns the smallest value in
g
. - To test this, you’ll need to use
currentMin
effectively. Initially, you’ll want a value larger than any other possible value.+inf.0
is a valid value in Racket representing the smallest possible value.
- Assume
(countDown n)
- Assume
n
is a positive integer. - Returns a list containing all the integers from
n
to0
.
- Assume
(doublify g)
- Assume
g
is a list containing only numbers. - Returns a list containing the values of
g
times 2.
- Assume
(myMap f g)
- Assume
f
is a function andg
is a list. - Works the same way as
map
, so it should return a new list wheref
is applied to each element ofg
.
- Assume
(reverse-build-list n f)
- Assume
n
in a positive integer andf
is a function. - Works like
build-list
but in reverse, so the first element should be(f n)
and the last should be(f 0)
. - Question to ponder: What would you need to do to get this to work the same way as
build-list
?
- Assume
-
Lab 01: A Game of Chance
Due: Thursday 10/24 10:00am
Submission name: New GH Classroom Link
All the instructions for this assignment can be found in README.md after you click the link above to make a new repository.
- Period 9: https://classroom.github.com/a/t2vvprgP
- Period 10: https://classroom.github.com/a/yGYJZ_sQ
Skills Assessed
Skill Minimal Competency Developing Competency Competency Mastery 3. Writing functions/procedures. Can write the contract for a function. Can write simple functions given a contract. Can write complex functions given a contract and can write contracts for functions given a specified task. Can write contracts for complex functions, implement those functions and create effective test cases for them. 4. Understanding Algorithms Can follow an algorithm to produce a desired outcome. Can break down a simple problem into basic steps that will result in a desired outcome. Can break down a problem into basic steps and implement those steps in code. Can analyze the differences between 2 or more algorithms that produce the same desired outcome. 5. Working with Boolean Values Understands the purpose of boolean values. Demonstrates the appropriate use of comparison operators. Demonstrates the appropriate use of comparison and boolean operators. Writes functions that take in boolean values and/or return boolean values. 6. Using Conditional Statements Can trace the result of a single conditional statement. Can write conditional statements with one or two results. Can write nested conditional statements. Can use at least two different kinds of conditional statements, and understand the benefits of each. 7. Using Randomness in Programs Can use one language provided random function. Can use a random function to generate integers or floating point values in a specified range. Can use random functions to produce random integers and floating point values within specified ranges. Can use random functions with conditional statements to write functions with randomly controlled outcomes. 9. Data Structures Understands the difference between single values and data structures. Can describe how one data structure stores data. Can use a data structure to store multiple values in a program. Can use language provided features to effectively create and access data in a data structure. 22. Using Variables Recognizes the difference between variables and literals Demonstrates ability to understand code which uses variables Correctly uses variables in programming Correctly uses the appropriate types of variables for different programming algorithms
-
Work 16: Test Prep, Part II
Due: Friday 10/18 10:00am
Submission name: work16.rkt
You can find all the submitted test questions here: https://github.com/mks21-dw/thesource/tree/main/racket/test01
Pick 4 of the programming questions to complete. At the beginning of each function you write, include the question number above as a comment. Be sure to include test cases with your program.
You are encouraged to work on more problems to prepare for the exam. You should also take a look at the multiple choice questions. I have not vetted all the questions, so there may be mistakes.
-
Test Prep 01: Questioning
Due: Thursday 10/17 10:00am
Submission name: test01.rkt
Write Possible Test Questions
With your TableBuddy™ write three potential test questions.
- The first two should be multiple choice questions with 4 options.
- The third one should be a function to program.
- This should be similar to the programming work you have had so far. Include all the information needed to write the function (formulas, etc).
Put both questions, and the answers in a racket file. You are working with your TableBuddy™, but if you dont finish in class you can both submit different files from home. You can put multiple lines together in a single comment using
#| .... |#
. Use this format:#lang racket #| MC Question: Skill: Options: Answer |# #| MC Question: Options: Skill: Answer |# #| Programming question: Skill: Description Possible solution: |# CODE GOES HERE
Here is a filled in Example:
#| MC Question: What is the air speed of an unladen swallow? Skill: 9001 Options: A) 2 mph B) 20 mph C) 200 mph D) African or European? Answer: D |# #| MC Question: Who you gonna call? Skill: 9001 Options: A) Transformers B) Ghostbusters C) Thundercats D) Teenage Mutant Ninja Turtles Answer: B |# #| Programming question: Skill: 2,3 Write a function that takes the radius of a circle and returns it's area. area = pi * r^2 Possible solution: |# (define areaC (lambda (radius) (* pi radius radius))) (areaC 10)
Test Friday, 10/18
Skill Minimal Competency Developing Competency Competency Mastery 3. Writing functions/procedures. Can write the contract for a function. Can write simple functions given a contract. Can write complex functions given a contract and can write contracts for functions given a specified task. Can write contracts for complex functions, implement those functions and create effective test cases for them. 5. Working with Boolean Values Understands the purpose of boolean values. Demonstrates the appropriate use of comparison operators. Demonstrates the appropriate use of comparison and boolean operators. Writes functions that take in boolean values and/or return boolean values. 6. Using Conditional Statements Can trace the result of a single conditional statement. Can write conditional statements with one or two results. Can write nested conditional statements. Can use at least two different kinds of conditional statements, and understand the benefits of each. 7. Using Randomness in Programs Can use one language provided random function. Can use a random function to generate integers or floating point values in a specified range. Can use random functions to produce random integers and floating point values within specified ranges. Can use random functions with conditional statements to write functions with randomly controlled outcomes. 9. Data Structures Understands the difference between single values and data structures. Can describe how one data structure stores data. Can use a data structure to store multiple values in a program. Can use language provided features to effectively create and access data in a data structure. 22. Using Variables Recognizes the difference between variables and literals Demonstrates ability to understand code which uses variables Correctly uses variables in programming Correctly uses the appropriate types of variables for different programming algorithms
-
Skills For Test
Test Friday, 10/18
Skill Minimal Competency Developing Competency Competency Mastery 3. Writing functions/procedures. Can write the contract for a function. Can write simple functions given a contract. Can write complex functions given a contract and can write contracts for functions given a specified task. Can write contracts for complex functions, implement those functions and create effective test cases for them. 5. Working with Boolean Values Understands the purpose of boolean values. Demonstrates the appropriate use of comparison operators. Demonstrates the appropriate use of comparison and boolean operators. Writes functions that take in boolean values and/or return boolean values. 6. Using Conditional Statements Can trace the result of a single conditional statement. Can write conditional statements with one or two results. Can write nested conditional statements. Can use at least two different kinds of conditional statements, and understand the benefits of each. 7. Using Randomness in Programs Can use one language provided random function. Can use a random function to generate integers or floating point values in a specified range. Can use random functions to produce random integers and floating point values within specified ranges. Can use random functions with conditional statements to write functions with randomly controlled outcomes. 9. Data Structures Understands the difference between single values and data structures. Can describe how one data structure stores data. Can use a data structure to store multiple values in a program. Can use language provided features to effectively create and access data in a data structure. 22. Using Variables Recognizes the difference between variables and literals Demonstrates ability to understand code which uses variables Correctly uses variables in programming Correctly uses the appropriate types of variables for different programming algorithms
-
Work 15: Folding
Due: Tuesday 10/15 10:00am
Submission name: work15.rkt
Reminder: Test Friday, 10/18
Write a Racket program with the following features:
If you need some assitance with this assignment, check out the list seciton of the textbook, as well as the solution to yesterday’s work
- A function
(randList n maxValue)
that will create a list ofn
random integers in the range [0, maxValue). - Use
randList
to Create a variable to store a random list of 20 integers in the range [0, 100). - Using
foldl
, write code that will:- Return the sum of all the elements in the list.
- Return the amount of elements in the list.
- Return the smallest value in the list.
- Using
filter
andfoldl
, write code that will:- Return the sum of the the odd numbers in your list.
- Return the amount of the numbers greater than or equal to 50.
Example output:
list: '(65 46 76 49 28 25 51 18 16 5 80 44 30 93 60 69 25 7 46 94) sum: 927 count: 20 smallest 5 odds: '(65 49 25 51 5 93 69 25 7) sum: 389 larger half count: 16
- A function
-
Work 14: Filter Feeders
Due: Friday 10/11 10:00am
Submission name: work14.rkt
Write a Racket program with the following features:
-
A function
(randList n maxValue)
that will create a list ifn
random integers in the range [0, maxValue). -
Use
randList
to Create a variable to store a random list of 20 integers in the range [0, 50). -
Using
filter
, write code that will:- Return a list containing only the odd numbers in your list.
- Return a list containing only the numbers greater than or equal to 25.
- Return a list containing only the numbers less than 25.
Example output:
list: '(46 40 4 34 15 29 30 20 49 42 10 16 35 8 11 30 20 19 48 17) odds: '(15 29 49 35 11 19 17) larger half: '(46 40 34 29 30 49 42 35 30 48) smaller half: '(4 15 20 10 16 8 11 20 19 17)
-
-
Work 13: List of Questions
Due: Thursday 10/10 10:00am
Submission name: work13.rkt
Part 0
Copy the following code into the definitions pane of DrRacket and run it. You should run it multiple times. Then answer the questions below:
(define a (list 51 2 21 42 46 20)) (display "useful output for questions 1-4\n") a (first a) (rest a) (define b (rest a)) (first b) (display "useful output for questions 5-6\n") (build-list 5 sqrt) (build-list 5 (lambda (x) (* x x))) (display "useful output for questions 7-9\n") (random) (random 2) (random 5 10)
Questions
Add a comment block
#| ... |#
and answer the following questions inside it.- What does
first
do? - What does
rest
do? - For this question, write new code at the end of the provided code. Using the list
a
as defined, how would you return the list starting at the number 21? - For this question, write new code at the end of the provided code. Using the list
a
as defined, how would you return the number21
? - What does
build-list
do? - For this question, write new code at the end of the provided code. Write a line of racket code that uses
build-list
to create a list of the first 5 perfect cubes. - What does
random
do if you give it no arguments? - What does
random
do if you give it one argument? - What does
random
do if you give it 2 arguments? - For this question, write new code at the end of the provided code. Write a line of racket code that uses
build-list
andrandom
to make a list of 10 random integers in the range [10, 20) (this includes 10 but excludes 20).
- What does
-
Lab 00: If I Could Flow Like a Master MC
Due: Wednesday 10/9 10:00am
Submission name: New GH Classroom Link
All the instructions for this assignment can be found in README.md after you click the link above to make a new repository.
- Period 9: https://classroom.github.com/a/t2I2aMNP
- Period 10: https://classroom.github.com/a/ym6nxL3d
Skills Assessed
Skill Minimal Competency Developing Competency Competency Mastery 3. Writing functions/procedures. Can write the contract for a function. Can write simple functions given a contract. Can write complex functions given a contract and can write contracts for functions given a specified task. Can write contracts for complex functions, implement those functions and create effective test cases for them. 4. Understanding Algorithms Can follow an algorithm to produce a desired outcome. Can break down a simple problem into basic steps that will result in a desired outcome. Can break down a problem into basic steps and implement those steps in code. Can analyze the differences between 2 or more algorithms that produce the same desired outcome. 5. Working with Boolean Values Understands the purpose of boolean values. Demonstrates the appropriate use of comparison operators. Demonstrates the appropriate use of comparison and boolean operators. Writes functions that take in boolean values and/or return boolean values. 6. Using Conditional Statements Can trace the result of a single conditional statement. Can write conditional statements with one or two results. Can write nested conditional statements. Can use at least two different kinds of conditional statements, and understand the benefits of each.
-
Work 12: Flow With The Code
Due: Monday 10/07 10:00am
Submission name: work12.rkt
Part 0
Create functions based on your flow charts from the previous assignment. Use the test cases you made from your test case flow charts. (you can also find example flowcharts here: https://github.com/mks21-dw/thesource/blob/main/flowcharts/work11.md)
You should have 4 functions:
- Square area
- Circle area
- Shape area
- Closer Number
Part 1
Create a function based on the following flowchart
flowchart TD; id0([fizzbuzz]) -- n --> id1[remainder n 15]; id1 -- result0 --> id2{if\nresult0 = 0}; id2 -- false --> id4(remainder n 3); id2 -- true --> id3([15]); id4 -- result1 --> id5{if\nresult1 = 0}; id5 -- false --> id7(remainder n 5); id5 -- true --> id6([3]) id7 -- result2 --> id8{if\nresult2 = 0}; id8 -- false --> id9([-1]); id8 -- true --> id10([5]);
-
Work 11: Data Flow
Due: Wednesday 10/02 10:00am
Submission name: work11.png (or other image file type)
For this assignment, you will be asked to make flowcharts. You can draw these by hand or using a computer drawing program. Instead of submitting a Racket programming file, upload an image containing both of your flowcharts. If you cannot fit all flow charts on one image, then name them
work11-0
andwork11-1
, and so on.For each flowchart, draw a general function flowchart followed by a test case chart. If the function has different possible results, make test case charts for each possible path.
- Square area
- Takes an input for the side length of a square.
- Outputs the area of that square.
- Circle area
- Takes an input for the radius of a circle
- Outputs the area of that circle.
- Shape Area
- Takes in 2 inputs.
- If the first input is even, output the area of a square using the second input as the side length.
- If the first input is odd, output the area of a circle using the second input as the radius.
- Closer Number
- Takes 3 numbers as inputs.
- Outputs whichever of the first 2 inputs is closer to the third input.
- By closeness we are referring to the distance between 2 numbers on a number line.
- The distance between 16 and 10 is 6
- The distance between 7 and 10 is 3
- 7 is closer to 10 than 16
Example Function Flowchart:
flowchart LR; id0([getTensDigit]) -- n --> id1[quotient\nn 10]; id1 -- result0 --> id2[remainder\nresult0 10]; id2 --> id3([result1]);
Example Test Case Flowchart:
flowchart LR; id0([getTensDigit]) -- 8765 --> id1[quotient\n8765 10]; id1 -- 876 --> id2[remainder\n876 10]; id2 --> id3([6]);
- Square area
-
Work 10: Test Prep
Due: Friday 09/27 10:00am
Submission name: work10.rkt
You can find all the submitted test questions here: https://github.com/mks21-dw/thesource/tree/main/racket/test00
Pick 4 of the programming questions to complete. At the beginning of each function you write, include the question number above as a comment. Be sure to include test cases with your program.
You are encouraged to work on more problems to prepare for the exam. You should also take a look at the multiple choice questions. I have not vetted all the questions, so there may be mistakes.
-
Test Prep 00: Questioning
Due: Thursday 09/26 10:00am
Submission name: test00.rkt
Write Possible Test Questions
With your TableBuddy™ write three potential test questions.
- The first two should be multiple choice questions with 4 options.
- The third one should be a function to program.
- This should be similar to the programming work you have had so far. Include all the information needed to write the function (formulas, etc).
Put both questions, and the answers in a racket file. You are working with your TableBuddy™, but both of you need to submit this file. You can put multiple lines together in a single comment using
#| .... |#
. Use this format:#lang racket #| MC Question: Options: Answer |# #| MC Question: Options: Answer |# #| Programming question: Description Possible solution: |# CODE GOES HERE
Here is a filled in Example:
#| MC Question: What is the air speed of an unladen swallow? Options: A) 2 mph B) 20 mph C) 200 mph D) African or European? Answer: D |# #| MC Question: Who you gonna call? Options: A) Transformers B) Ghostbusters C) Thundercats D) Teenage Mutant Ninja Turtles Answer: B |# #| Programming question: Write a function that takes the radius of a circle and returns it's area. area = pi * r^2 Possible solution: |# (define areaC (lambda (radius) (* pi radius radius))) (areaC 10)
Skills For Test I
Skill Minimal Competency Developing Competency Competency Mastery 2. Using Functions Can explain the concept of a function. Uses a single function to produce a desired outcome. Combines multiple functions to produce a desired outcome. Appropriately uses functions that return and do not return values, combining them to produce a desired outcome. 3. Writing functions/procedures. Can write the contract for a function. Can write simple functions given a contract. Can write complex functions given a contract and can write contracts for functions given a specified task. Can write contracts for complex functions, implement those functions and create effective test cases for them. 5. Working with Boolean Values Understands the purpose of boolean values. Demonstrates the appropriate use of comparison operators. Demonstrates the appropriate use of comparison and boolean operators. Writes functions that take in boolean values and/or return boolean values. 22. Using Variables Recognizes the difference between variables and literals Demonstrates ability to understand code which uses variables Correctly uses variables in programming Correctly uses the appropriate types of variables for different programming algorithms 23. How Functions Operate Knows the difference between calling and defining a function Can correctly define and call functions Understands, in general terms, the difference between what happens in the computer when you define or when you call a function. Can correctly explain what happens in the computer when a function is called and when a function is defined, using the correct vocabulary (ex, parameters/arguments).
-
Work 09: Polish your Flow
Due: Wednesday 09/25 10:00am
Submission name: work09.png (or other image file type)
For this assignment, you will be asked to make five flowcharts. You can draw these by hand or using a computer drawing program. Instead of submitting a Racket programming file, upload an image containing both of your flowcharts. If you cannot fit all flow charts on one image, then name them
work09-0
andwork09-1
, and so on.Flowchart 1: Study for a test.
- Make a flowchart demonstrating how you study for an exam.
- Your chart should include at least 1 decision and 3 processes.
Flowchart 2:
- Make a flowchart that provides instructions for drawing one of the two shapes below (pick your favorite):
Flowchart 3:
- Start with a number. If that number is odd, return the ones digit of the number, if it is even, return the tens digit.
Flowchart 4:
- Write a flowchart for one of the functions from work07. Include a version with example values worked out.
Flowchart 5:
- Write a flowchart for one of the functions from work08. Include a version with example values worked out.
-
Work 08: Further Truth-Seeking
Due: Tuesday 09/24 10:00am
Submission name: work08.rkt
Write contracts and the functions for the following:
Use
define
andlambda
to write your functions. Include test cases with descriptive output. You will have to create your own test cases.isEven
- Has 1 parameter that is a number.
- Returns
true
if the parameter is evenfalse
in all other cases
isMultiple
- Has 2 number parameters (let’s call them n and m)
- Returns:
true
ifn
is a multiple ofm
false
in all other cases
twoDigits
- Has 1 positive integer parameter
- Returns:
true
if the parameter is a 2 digit numberfalse
in all other cases
xDigits
- Has 2 positive integer parameters (lets call them n and x)
- Returns:
true
n is an x digit number.false
in all other cases
Skills For Test I
Skill Minimal Competency Developing Competency Competency Mastery 2. Using Functions Can explain the concept of a function. Uses a single function to produce a desired outcome. Combines multiple functions to produce a desired outcome. Appropriately uses functions that return and do not return values, combining them to produce a desired outcome. 3. Writing functions/procedures. Can write the contract for a function. Can write simple functions given a contract. Can write complex functions given a contract and can write contracts for functions given a specified task. Can write contracts for complex functions, implement those functions and create effective test cases for them. 5. Working with Boolean Values Understands the purpose of boolean values. Demonstrates the appropriate use of comparison operators. Demonstrates the appropriate use of comparison and boolean operators. Writes functions that take in boolean values and/or return boolean values. 22. Using Variables Recognizes the difference between variables and literals Demonstrates ability to understand code which uses variables Correctly uses variables in programming Correctly uses the appropriate types of variables for different programming algorithms 23. How Functions Operate Knows the difference between calling and defining a function Can correctly define and call functions Understands, in general terms, the difference between what happens in the computer when you define or when you call a function. Can correctly explain what happens in the computer when a function is called and when a function is defined, using the correct vocabulary (ex, parameters/arguments).
-
Work 07: Searching for Truth
Due: Friday 09/20 10:00am
Submission name: work07.rkt
Chapter 5 covers boolean values and operators.
Write contracts and the functions for the following:
Use
define
andlambda
to write your functions. Include test cases with descriptive output.isBetween
- Takes 3 numbers as inputs (let’s call them a, b and c)
- Returns:
true
if a is greater than b and a is less than cfalse
in all other cases
- Examples:
(isBetween 5 4 6) ==> true (isBetween 3 7 9) ==> false (isBetween 4 4 9) ==> false
pythTriple
- Takes 3 numbers as inputs (let’s call them a, b and c)
- Returns:
true
if the three inputs could be the sides of a right triangle, with the last parameter being the hypotenusefalse
in all other cases
- Examples:
(pythTriple 3 4 5) ==> true (pythTriple 6 7 10) ==> false (pythTriple 4 3 5) ==> true (pythTriple 5 3 4) ==> false
pythTriple2
- Takes 3 numbers as inputs (let’s call them a, b and c)
- Returns:
true
if the three inputs could be the sides of a right triangle, where any of the sides could be the hypotenusefalse
in all other cases- Examples:
(pythTriple2 3 4 5) ==> #true (pythTriple2 6 7 10) ==> #false (pythTriple2 4 3 5) ==> #true (pythTriple2 5 3 4) ==> #true (pythTriple2 4 5 3) ==> #true
exor
- This is known as the exclusive or operator
- Takes 2 boolean values as inputs
- Returns:
true
if exactly one of the 2 inputs is truefalse
in all other cases- Examples:
(exor #true #true) ==> false (exor #true #false) ==> true (exor #false #true) ==> true (exor #false #false) ==> false (exor (> 3 4) (<= 5 6)) ==> true
-
Work 06: Living in a Digital World
Due: Thursday 09/19 10:00am
Submission name: work06.rkt
For the following functions, you should look back at the
quotient
andremainder
functions.Write the Following Functions given the contracts.
Paste the contracts into your racket program when starting. Use
define
andlambda
to write your functions. Include test cases with descriptive output.;(getOnesDigit n) --> integer ; n : non negative integer ; ; Returns the ones digit of n ; (getOnesDigit 7) --> 7 ; (getOnesDigit 4132) --> 2
;(removeOnesDigit n) --> integer ; n : non negative integer ; ; Returns n with the ones digit removed and all other digits shifted to the right. ; If the argument given is a one digit number, returns `0`. ; (removeOnesDigit 7) --> 0 ; (removeOnesDigit 4132) --> 413
Write contracts and the functions for the following:
getTensDigit
- Takes in a non-negative integer.
- Returns the tens place digit of that number.
- If the argument given is a one digit number, returns
0
. - You can assume only valid inputs will be used.
- Examples:
(getTensDigit 7)
==>0
(getTensDigit 4132)
==>3
getNthDigit
- Takes in two non-negative integers (
n
anddigit
). - Returns the number at the
digit
place ofn
. - If
digit
is1
, return the ones digit, ifdigit
is2
return the tens digit… - If
n
does not have a digit at thedigit
place, return0
- You can assume
n
is a non-negative integer. - You can assume
digit
is a positive integer. - Examples:
(getNthDigit 7 1)
==>7
(getNthDigit 4132 2)
==>3
(getNthDigit 4132 3)
==>1
-
Work 05: Contractors
Due: Wednesday 09/18 10:00am
Submission name: work05.rkt
Function Contracts
A function contract is a way to document a function within your code. Contracts contain the following information:
- Template function call using variables.
- The type of value to be returned by the function.
- The type of value represented by each parameter.
- A description of what the function does.
- One (or more) samples with input values and expected outputs.
Sample contract:
; (hypot a b) --> number ; a : number ; b : number ; Returns the lenght of the hypotenuse of a right traingle with legs of length a and b. ; (hypot 3 4) --> 5
Write the Following Functions given the contracts.
Paste the contracts into your racket program when starting. Use
define
andlambda
to write your functions. Include test cases with descriptive output.; (perimFromArea a) --> number ; a : number ; Returns the perimeter of that square whose area is a ; (perimFromArea 25) --> 20 ; (perimFromArea 10) --> 12.649110640673518
; (f_to_c temp) --> number ; temp : number ; Returns temp converted from farenheit to celsius ; (f_to_c 212) --> 100
Tip: \(C = (F-32)\dfrac{5}{9}\)
Write contracts and the functions for the following:
cost
- Returns the cost of a ticket to the Totally Real Not Made Up Amazing Museum of Racket Exercises.
- The cost of admission depends on a base amount and a discount rate.
- Cost is calculated by:
base + base * rate
. - Write the function
(cost base rate)
that will return the cost using the formula above. - Example:
(cost 10 0.25)
==>12.5
groupCost
- Returns the total cost of the tickets for a school trip to the Totally Real Not Made Up Amazing Museum of Racket Exercises
- The base cost for students is $5, and the discount rate is 0.5.
- The base cost for teachers is $10, and the discount rate is 0.75.
- The base cost for other adults is $10, and the discount rate is 1.
- Write the function
(groupCost students teachers adults)
that returns the total cost of the tickets given the amounts provided as parameters, using thecost
formula. - Example:
(groupCost 34 2 2)
==>330.0
Submitting your work using GitHub Classroom:
- Join the GitHub classroom assignment via the correct link:
- Period 9: https://classroom.github.com/a/pQDHKUhf
- Period 10: https://classroom.github.com/a/L22rWK5Q
- After following that link, click “Accept this assignment”
- After ~1 minute (maybe less), refresh the page.
- You should see a link that looks something like: https://github.com/stuycs-gh-classrooms/09-fcs-dw-work-jonalf
- The end of that url will differ based on your GitHub username and the beginning by your class period. Click on that url.
- This is where you will submit all your work, bookmark this page.
- This will create a GitHub repository for you, and add a basic
README.md
file to it.
- You will be taken to the repository page for your work. You will see the contents of
README.md
, which should display: “Work For NeXtCS” and then “Name: YOUR NAME HERE”. - Edit
README.md
by clicking on the pencil icon found to the far right ofREADME.md
- Replace “YOUR NAME HERE” with your full name, first then last (use preferred name if you’d like).
- Find the “Commit changes” button and click it.
- When you’ve finished the homework, use the “Add File -> Upload Files” button to upload your
work03.rkt
file.
Important Notes:
- Use the submission name listed above as the file name for your work.
- Make sure you are using the definitions pane to write your programs, and that you are saving that area when submitting.
- Use the interactions pane to test your code, but you do not submit what is there.
- The CS Dojo starts today! If you want to get a leg up, stop by 307 from 3:45 - 5!
- If you are having difficulty getting DrRacket to work on your computer, you can use this online editor:
Work Task:
- Read chapter 4 of the online textbook.
- Take the 3 formulas from the previous assignment, and make the functions using
lambda
anddefine
. - If done correctly, this code should work (as long as you named the functions the same as I did):
(triArea 12 5) (celToFaran 100) (gravity 27 2 3)
-
Work 04: Let's Get Fun-cy!
Due: Tuesday 09/18 10:00am
Submission name: work04.rkt
Submitting your work using GitHub Classroom:
- Join the GitHub classroom assignment via the correct link:
- Period 9: https://classroom.github.com/a/pQDHKUhf
- Period 10: https://classroom.github.com/a/L22rWK5Q
- After following that link, click “Accept this assignment”
- After ~1 minute (maybe less), refresh the page.
- You should see a link that looks something like: https://github.com/stuycs-gh-classrooms/09-fcs-dw-work-jonalf
- The end of that url will differ based on your GitHub username and the beginning by your class period. Click on that url.
- This is where you will submit all your work, bookmark this page.
- This will create a GitHub repository for you, and add a basic
README.md
file to it.
- You will be taken to the repository page for your work. You will see the contents of
README.md
, which should display: “Work For NeXtCS” and then “Name: YOUR NAME HERE”. - Edit
README.md
by clicking on the pencil icon found to the far right ofREADME.md
- Replace “YOUR NAME HERE” with your full name, first then last (use preferred name if you’d like).
- Find the “Commit changes” button and click it.
- When you’ve finished the homework, use the “Add File -> Upload Files” button to upload your
work03.rkt
file.
Important Notes:
- Use the submission name listed above as the file name for your work.
- Make sure you are using the definitions pane to write your programs, and that you are saving that area when submitting.
- Use the interactions pane to test your code, but you do not submit what is there.
- The CS Dojo starts today! If you want to get a leg up, stop by 307 from 3:45 - 5!
- If you are having difficulty getting DrRacket to work on your computer, you can use this online editor:
Work Task:
- Read chapter 4 of the online textbook.
- Take the 3 formulas from the previous assignment, and make the functions using
lambda
anddefine
. - If done correctly, this code should work (as long as you named the functions the same as I did):
(triArea 12 5) (celToFaran 100) (gravity 27 2 3)
- Join the GitHub classroom assignment via the correct link:
-
Work 03: Defining Success
Due: Monday 09/16 10:00am
Note: Check your language in DrRacket. Go to the Language menu, select Choose Language, the first option is “The Racket Language”, Pick that one.
Write a Racket program that uses variables to run the following formulas with values of your choosing. This is what we did in class today with the pythagorean theorem.
- Example: Pythagorean Theorem
- Forumula: \(c = \sqrt{a^2 + b^2}\)
- Racket expression:
(sqrt (+ (* a a) (* b b)))
- Variables:
a b
- Program:
(define a 3) (define b 4) (sqrt (+ (* a a) (* b b)))
Create a single Racket file named
work03.rkt
with the code for the three formulas below:- Area of triangle:
- \[A = \dfrac{1}{2}bh\]
- Celsius to Fahrenheit:
- \[F = \dfrac{9}{5}C+32\]
- Gravity:
- \[G = \dfrac{m_1m_2}{d^2}\]
- Example: Pythagorean Theorem
-
Work 02: Pre-fecting your work
Due: Friday 09/13 start of class
Translate the following expressions into valid Racket code. Test them in DrRacket and write your solutions in your notebook.
- (2 + 3) / 4
- 2 / (3 + 4 * 5)
- 2 * 3 + 4 / 5 + 6 * 7
- \[\dfrac{5+4}{15-2}\]
- \[\dfrac{7+5\sqrt{9}}{2^2+\dfrac{12}{4}}\]
In case you are interested in the video from yesterday, follow this youtube link. The link will take you to about 36 minutes into an hour talk, where the speaker starts discussing the Shakespeare language.
-
Work 01: Preparations
Due: Thursday 09/12 10:00am
Over the semester, Computer Science teachers will be working on an online textbook as a companion for this course. You cand find the book here:
- http://www.stuycs.org/fcs00-book/my-great-book.html (pardon the url, the book is very much in progress).
- To help prepare for our journey into the Racket programming language, read Chapter 3 direct link.
- As you read, write down any questions in your notebook. Come to class prepared to discuss.
- Download and install DrRacket from here: https://download.racket-lang.org/
-
Work 00: Getting to Know You
Due: Monday 09/09 10:00am
- Please fill out the student info form found here: https://forms.gle/Ebb89dHHXnmY7NC16
- You will need a GitHub account in order to submit work for this class. If you don’t have one already, go to https://github.com/ and create one.
- Read and acknowledge the Stuyvesant Computer Science Lab and Network Usage Policy