Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# Assignment: functions

## How to clone this repo

Clone this repository by clicking the green button in the upper right corner, selecting `SSH` and copying the string that looks like `git@github.com:code4policy/<REPO-NAME>.git` (`<REPO-NAME>` will be the name of your repository). Then, in the terminal run the following:

```
git clone git@github.com:code4policy/<REPO-NAME>.git
```

Note that by default, git will clone the repository into a folder with name `<REPO-NAME>`. After the repo is cloned, open that directory (use `cd`).
As usual, clone this repo to your `assignments` directory (or wherever you like to work).

## Python

Expand Down Expand Up @@ -53,7 +45,6 @@ pip install pytest # install the pytest package
10. Make sure everything works correctly and issue a pull request on github back to the main branch with a message explaining what changes you made in this branch.

11. Accept the pull request into the main branch and delete the `calculator` branch on github.

12. Checkout the main branch, and pull the version of main with the calculator branch merged

```
Expand All @@ -67,12 +58,18 @@ pip install pytest # install the pytest package
git branch -D calculator
```

14. Add two more functions, `square` and `cube`. both should take a single number as an argument and return the number raised to the appropriate power.
14. Create a new branch from `main`. In the new branch, add two more functions, `square` and `cube`. both should take a single number as an argument and return the number raised to the appropriate power.
15. Make a function called `square_n_times` that takes two arguments, `number` and `n`. Have the function square the number `n` times and return the sum.
16. PR the new branch to `main`. Your `calcluator.py` in `main` should now have functions for addition, subtraction, multiplication, division, squaring, cubing, and adding squares `n` times.

## Javascript (ungraded)

1. create a new branch in your `assignments` git repo called "js-calculator"
### Install `node`
On WSL: `sudo apt-get install npm`
On Mac: `brew install npm`

### Tasks
1. create a new branch `js-calculator`
2. inside that branch create a new file called `calculator.js`

3. Write (in javascript) a program that defines four functions (multiply, add, subtract, and divide). These functions should not print anything, they should simply perform a mathematical operation on the two arguments and return the value.
Expand Down
Binary file modified __pycache__/calculator.cpython-312.pyc
Binary file not shown.
5 changes: 5 additions & 0 deletions calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ def subtract(a,b):
def divide(a,b):
return a/b

def square(a):
return a**2

def cube(a):
return a**3

print("I'm going use the calculator functions to multiply 5 and 6")
x = multiply(5,6)
Expand Down