• Work 06: Testing your patience

    Due: Thursday 9/18 10:00am

    Submission name: work06.rkt

    Quiz Friday to cover skills 1, 2 and 3

    1. If you have completed assignments 3, 4 and 5, you will have written a total of 11 functions.
    2. If you did not get all of these working, you can find them in the newly published solutions repository.
    3. Using either your work or the solutions provided, collect all 11 functions into a single racket program.
    4. Add what is needed so every function has the following:
      • A contract following the format we’ve been using.
      • Test cases.
      • Desciptive output that uses the display function

  • Work 05: Contractors

    Due: Wednesday 9/17 10:00am

    Submission name: work05.rkt

    Write the Following Functions given the contracts.

    Paste the contracts into your racket program when starting. Use define and lambda 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 the cost formula.
    • Example:
      • (groupCost 34 2 2) ==> 330.0

  • Work 04: Living in a Digital World

    Due: Tuesday 9/16 10:00am

    Submission name: work04.rkt

    For the following functions, you should look back at the quotient and remainder functions.

    Write the Following Functions given the contracts.

    Paste the contracts into your racket program when starting. Use define and lambda 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 and digit).
    • Returns the number at the digit place of n.
    • If digit is 1, return the ones digit, if digit is 2 return the tens digit…
    • If n does not have a digit at the digit place, return 0
    • 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 03: Let's Get Fun-cy!

    Due: Monday 9/15 10:00am

    Submission name: work03.rkt

    Programming:

    • Read chapter 4 of the online textbook.
    • Take the 3 formulas from the previous assignment, and make the functions using lambda and define.
    • 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)
      

    Submitting your work using GitHub Classroom:

    1. Join the GitHub classroom assignment via the correct link:
    2. After following that link, click “Accept this assignment”
    3. After ~1 minute (maybe less), refresh the page, a link should appear. 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.
    4. You will be taken to the repository page for your work. You will see the contents of README.md.
    5. Edit README.md by clicking on the pencil icon found to the far right of README.md
      • Replace “YOUR NAME HERE” with your full name, first then last (use preferred name if you’d like).
      • Replace “CLASS PERIOD HERE” with your foundations class period.
    6. Find the “Commit changes” button and click it.
    7. When you’ve finished the homework, use the “Add File -> Upload Files” button to upload your work03.rkt and work02.rkt files.

    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 Monday! 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 02: Defining Success

    Due: Friday 9/12 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 work02.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}\]

    Print out, or write down on paper, your solutions. Tomorrow in class we will discuss how we will be using github to submit work going forward.


  • Work 01: Preparations

    Due: Thursday 09/11 10:00am

    Setup

    Over the semester, Computer Science teachers will be working on an online textbook as a companion for this course. You can find the book here:

    • http://www.stuycs.org/fcs00-book/my-great-book.html (pardon the url, the book is a work in progress).
    • To help prepare for our journey into the Racket programming language, read Chapter 3.
      • 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/
      • When you first open DrRacket, you will see a message about selecting a language in the interactions pane. Go to the Language menu, select Choose Language, the first option is The Racket Language, Pick that one.

    Programming

    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}}\]

    Enrichment

    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 00: Getting to Know You

    Due: Monday 09/08 10:00am

    1. Please fill out the student info form found here: https://forms.gle/MM878Fp9hAqtGc9V9
    2. 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.
    3. Read and acknowledge the Stuyvesant Computer Science Lab and Network Usage Policy
      • As you read through this policy, write down anything you see that you have a question about. We will use these questions to seed our discussion in class.