Skip to content
This repository was archived by the owner on Mar 26, 2024. It is now read-only.

Commit a3a70ca

Browse files
committed
initial revamp commit
1 parent dc46ea7 commit a3a70ca

File tree

2 files changed

+62
-99
lines changed

2 files changed

+62
-99
lines changed

README.md

+58-93
Original file line numberDiff line numberDiff line change
@@ -21,116 +21,100 @@ export EDITOR="pluma"
2121
```
2222
> This only lasts as long as the terminal window you ran it within. As soon as you close the window, this setting is lost.
2323
24-
### Repository Setup
25-
#### Do WITH partner on ONE computer
26-
27-
1. Fork this repository
28-
29-
> Forking a repo
30-
31-
> ![*Creating a Repo*](https://github.com/PurdueCS190/lab7/blob/master/res/fork_repo.jpg)
32-
33-
> Note: This time we are forking, but you can also create a brand new repository by clicking the
34-
plus button at the top of your screen and following the instructions.
35-
36-
2. Add your partner as a collaborator
24+
### Git Setup
25+
Required since git 2.0, it defines how the pushing mechanism works. This is the most intuitive option.
26+
```bash
27+
git config --global push.default simple
28+
```
3729

38-
> Go to the repo settings
30+
### Creating, Committing, and Pushing
31+
Choose a partner to start this project off.
3932

40-
> ![*Go to the repo's settings*](https://github.com/PurdueCS190/lab7/blob/master/res/repo_settings.jpg)
33+
Agree on who is partner #1 and partner #2
34+
#### Do WITH partner on partner #1's computer
4135

42-
> Add your partner as a collaborator
36+
1. In your home directory, create a new folder named `cs190lab7_<your_username>`. Ex. I would create a folder `cs190lab7_sopell`.
4337

44-
> ![Add your partner](https://github.com/PurdueCS190/lab7/blob/master/res/add_collab.jpg)
38+
```bash
39+
mkdir ~/cs190lab7_$USER
40+
```
4541

46-
### Clone the Repository
47-
#### Do on both computers
42+
2. You will then `cd` into the directory created above and `init`ialize a new git repository.
4843

49-
1. Copy the clone URL from Github to your clipboard. There is a special button that makes it very simple to do this.
50-
Make sure that the HTTPS protocol is selected *(Bonus: See end of lab for instructions to set up SSH keys)*
44+
```bash
45+
cd ~/cs190lab7_$USER
46+
git init
47+
```
5148

52-
2. Navigate to your home directory
49+
3. Download this template file [`calc.py`](./calc.py) into the repository you just created
5350

54-
3. Create and navigate to a new directory called `cs190/`
55-
56-
```bash
57-
mkdir cs190/
58-
cd cs190/
59-
```
51+
```bash
52+
wget -O ~/cs190lab7_$USER/calc.py https://github.com/purduecs190/lab7/raw/master/calc.py
53+
```
6054

61-
4. Run the command `$ git clone <clone URL>` pasting in the URL you just copied
55+
4. `add` this file to the repo
6256

63-
5. Navigate into the repository
57+
```bash
58+
git add <filename>
59+
```
6460

65-
When the repository is cloned, the `origin` remote, is automatically created as the the location you cloned
66-
from. Run the command `$ git remote -v`. You get output that looks something like:
61+
5. Log in to github (upper right hand corner of this page)
6762

68-
```bash
69-
origin https://github.com/<username>/lab7.git (fetch)
70-
origin https://github.com/<username>/lab7.git (push)
71-
```
63+
6. Create a new repository
64+
![new repo button](http://i.imgur.com/Lhj1dUJ.png)
7265

73-
### Run the Script
66+
7. Enter in a repository name and do **not** check the box that says initialize with README.
7467

75-
To run the calculator script, run the command `$ python calc.py`. The program will prompt you to enter input. Notice
76-
That addition works, but all the other operations return 0. You will implement them today.
68+
8. Go to the repository settings
69+
![settings location](http://i.imgur.com/qJAv62R.png)
7770

78-
### Implement the Calculator
71+
9. Add your partner as a collaborator.
7972

80-
Now it is time to implement. Follow these instructions carefully.
8173

82-
1. Open up `calc.py` in your text editor (`$ pluma calc.py &`)
74+
## Move to Partner #2's computer
75+
Partner 2 needs a copy of this repo. If you remember from lecture, this is exactly what `clone` does.
8376

84-
2. Implement the functions that do subtraction, multiplication, and division.
77+
```bash
78+
git clone <remote url>
79+
cd <repo name>
80+
```
8581

86-
> __Partner 1__:
82+
For the rest of this lab, pay attention to which section you're supposed to do.
8783

88-
* Implement __*sub(a, b)*__ and __*mult(a, b)*__.
8984

90-
* For multiplication, you must use the add operator (+) and a for loop.
85+
## **Both** partners independently
86+
### Run the Script
9187

92-
*Hint*: in Java you may implement this
93-
94-
```Java
95-
int mult(int a, int b) {
96-
int result = 0;
97-
for (var i = 0; i < a; i++) {
98-
result += b;
99-
}
100-
return result;
101-
}
102-
```
88+
To run the calculator script, run the command `$ python calc.py`. The program will prompt you to enter input. Notice that there are 4 functions defined, `+, -, * and /`
10389

104-
In Python, to iterate *n* times, you can do
90+
### Implement New Operations
91+
By the time you're done, you'll have two new operators, modulus division and exponentiation. One partner will do each.
10592

106-
```Python
107-
for i in range(n):
108-
print i
109-
```
93+
> Note: If you have any questions about Python syntax, ask your TA. It should be very straightforward.
11094
111-
> __Partner 2__:
95+
> Be sure to test your code to make sure your functions work the way that they should.
11296
113-
* Implement __*mult(a, b)*__ and __*div(a, b)*__.
11497

115-
* For multiplication, you may use the multiply operator (*)
98+
1. Open up `calc.py` in your text editor (`$ pluma calc.py &`)
11699

117-
> Notice that you will both be implementing __*mult(a, b)*__.
100+
### Partner 1 only
101+
2. Implement modulus division operator (%)
118102

119-
> Note: If you have any questions about Python syntax, ask your TA. It should be very straightforward.
103+
> hint: what you're doing is very very similar to the div operator, but instead of using `/` to do regular division, you can use the `%` operator to do modulus division.
120104
121-
> Be sure to test your code to make sure your functions work the way that they should.
105+
### Partner 2 only
106+
2. Implement the exponent operator (**)
107+
> hint: what you're doing is very very similar to the multiplication operator, but instead of using `*`, you can use the `**` operator.
122108
123109
3. When you are done with your implementation, commit your changes
124110

125-
> Remeber `git add` and `git commit`. Be sure to check `git status` and `git log` afterward to make sure you
126-
successfully commited the changes.
111+
> Remember `git add` and `git commit`. Be sure to check `git status` and `git log` afterward to make sure you successfully committed the changes.
127112
128113
4. Do a git pull to check for any changes. Run `$ git pull origin master`
129114

130-
> If you are the second partner to finish your implementation, you will get a merge conflict. Don't panic. Skip to the
131-
next section and fix it together with your partner.
115+
* If you are the second partner to finish your implementation, you will get a merge conflict. Don't panic. Skip to the next section and fix it together with your partner.
132116

133-
> If you are the first partner to finish your implementation, move on to step 5.
117+
* If you are the first partner to finish your implementation, move on to step 5.
134118

135119
5. Do a git push to publish your changes to Github so your partner can see them. Run `$ git push origin master`
136120

@@ -160,25 +144,6 @@ This is because both of you implemented the __*mult(a, b)*__ function. Let's fix
160144
Now both of you should be able to run `$ python calc.py` on your separate computers and have a fully functioning
161145
calculator CLI.
162146

163-
### Participating in open source
164-
165-
Open source projects are a great way to get experience in the computer science community. Not only are they free and fun to work on,
166-
but contributions to open source are serious resume items that companies will love to see. Github is one of the biggest open source
167-
hosting platforms out there.
168-
169-
When contributing to open source projects, you have to fork the repository. This gives you a copy of the repository on your own
170-
account where you have the permissions to change things. If you create a feature that you think is worth adding to the main project,
171-
you can submit a pull request and the maintainers of the project can merge in your changes. Lots more information on contributing
172-
to open source can be found [here](https://guides.github.com/activities/contributing-to-open-source/).
173-
174-
1. Find an open source project on Github that interests you. Some good ideas [here](https://github.com/explore)
175-
176-
2. Fork the repository (the same way you did earlier in the lab)
177-
178-
3. Clone the forked repository to your machine
179-
180-
Now your all set! If you want to contribute to the project you have the knowledge and tools to do so.
181-
182147
### Grading
183148

184149
* Run `$ git log -3` and show it to your TA
@@ -194,6 +159,6 @@ you are using the HTTPS protocol to connect to Github as a remote. This has a fe
194159
* It will still work on strict firewalls and proxies such as those restricting all ports but port 80
195160

196161
The downside is that you don't want to have to enter your credentials everytime you push and pull. There is another way. You
197-
can set up the remote to use SSH instead of HTTPS. SSH uses RSA encryption which you can set up to be passwordless using
162+
can set up the remote to use SSH instead of HTTPS. SSH uses RSA encryption which you can set up to be passwordless using
198163
public keys. There is a great tutorial by Github on how to set up and use this method [here](https://help.github.com/articles/generating-ssh-keys/).
199164
Note that you will need to add an SSH key for every different machine you want to clone on.

calc.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,20 @@ def add(a, b):
1919
# a -- minuend
2020
# b -- subtrahend
2121
def sub(a, b):
22-
# TODO -- implement subtraction here
23-
return 0
22+
return a - b
2423

2524
# Multiply function
2625
# a -- multiplicand
2726
# b -- multiplier
2827
def mult(a, b):
29-
# TODO -- implement multiplication here
30-
return 0
28+
return a * b
3129

3230
# Divide function
3331
# a -- dividend
3432
# b -- divisor
3533
def div(a, b):
36-
# TODO -- implement division here
37-
return 0
34+
return a / b
35+
3836

3937
# -------------------------------------------------------- #
4038

0 commit comments

Comments
 (0)