You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 26, 2024. It is now read-only.
Now it is time to implement. Follow these instructions carefully.
81
73
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.
83
76
84
-
2. Implement the functions that do subtraction, multiplication, and division.
77
+
```bash
78
+
git clone <remote url>
79
+
cd<repo name>
80
+
```
85
81
86
-
> __Partner 1__:
82
+
For the rest of this lab, pay attention to which section you're supposed to do.
87
83
88
-
* Implement __*sub(a, b)*__ and __*mult(a, b)*__.
89
84
90
-
* For multiplication, you must use the add operator (+) and a for loop.
85
+
## **Both** partners independently
86
+
### Run the Script
91
87
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 /`
103
89
104
-
InPython, 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.
105
92
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.
110
94
111
-
> __Partner 2__:
95
+
> Be sure to test your code to make sure your functions work the way that they should.
112
96
113
-
*Implement __*mult(a, b)*__ and __*div(a, b)*__.
114
97
115
-
*For multiplication, you may use the multiply operator (*)
98
+
1. Open up `calc.py` in your text editor (`$ pluma calc.py &`)
116
99
117
-
>Notice that you will both be implementing __*mult(a, b)*__.
100
+
### Partner 1 only
101
+
2. Implement modulus division operator (%)
118
102
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.
120
104
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.
122
108
123
109
3. When you are done with your implementation, commit your changes
124
110
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.
127
112
128
113
4. Do a git pull to check for any changes. Run `$ git pull origin master`
129
114
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.
132
116
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.
134
118
135
119
5. Do a git push to publish your changes to Github so your partner can see them. Run `$ git push origin master`
136
120
@@ -160,25 +144,6 @@ This is because both of you implemented the __*mult(a, b)*__ function. Let's fix
160
144
Now both of you should be able to run `$ python calc.py` on your separate computers and have a fully functioning
161
145
calculator CLI.
162
146
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
-
182
147
### Grading
183
148
184
149
* 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
194
159
* It will still work on strict firewalls and proxies such as those restricting all ports but port 80
195
160
196
161
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
198
163
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/).
199
164
Note that you will need to add an SSH key for every different machine you want to clone on.
0 commit comments