# Using PyCharm and submitting assignments
This course will have weekly assignments. Lab time each week will be used
to complete the first part of each assignment and to ensure that you have
all the tools and skills to successfully complete the assignment.
Most assignments have a second part, which you may finish and
submit later.
For most assignments, you will be required to do a little pre-lab study
and answer a few planning questions before the start of the lab.
In general, for lab time to be as effective as possible you should
review your lecture notes, the reading and the assignment before coming to lab.
You might want to have the online copy of the textbook, and/or the
documentation available through [python.org](http://python.org),
on your screen while you work through the lab exercises.
The purpose of this first lab is to ensure that you:
1. can log in to the lab machines.
2. have a working PyCharm development environment (optionally on your
own personal machine).
3. can create a PyCharm project and download/import sample/starter code into it.
4. can create and execute simple Python programs
5. can properly use the automated submission system.
| Part | Section |
|---------------|-----------------------------------------------|
| 1 (in-lab) | [Description](#part1) |
| 1 (in-lab) | [Check-in Instructions](#checkin) |
| 2 (lab/home) | [Description](#part2) |
| 2 (lab/home) | [Submission Instructions](#submission) |
## Part 1: Bring up PyCharm and create a simple project
In this class we'll work within the PyCharm integrated development
environment, so this part gets you started with using the interpreter
through PyCharm. In Part 1 of this lab you will:
- log into a lab machine
- (optional) install Python 3.7 and PyCharm on your personal machine
- create a PyCharm workspace and start PyCharm
- create a new Python project and download/import a starter
- edit and run this program
The focus of Part 1 is to get you familiar with PyCharm, the IDE that we'll
be using for the rest of the semester. You should feel free to ask each other
for help, to check your answers with each other, and so on. In fact, for today,
you should make sure to ask for help if at any point the instructions
about PyCharm setup seem confusing. We really want everyone's workspace
to be set up the same way so that instructions for subsequent assignments make sense!
Finally, while you're encouraged to talk to one another, you need to
make sure that you fully understand the material. Before you can
receive the points for Part 1, you'll need to find an instructor or
a TA. We'll look over your work and ask you some questions about the
content. Then we'll give you points.
### 1.1 Logging in
You should be able to log into any lab machine using your
Computer Science (CS) account Username and Password.
It does not matter which lab machine you log in to. Any lab
machine should recognize your account and take you to the same
Desktop.
The first time you log in the system may be very slow, as it creates
a new Desktop for you (and because many other students may be doing
this at the same time). If you attempt to login to a lab machine
before the lab, you can (a) get this over with
and (b) deal with any problems before the actual start of the lab.
If you are unable to log in to a lab machine with your CS account
Username and Password, ask our administrator (Corey LeBlanc, who's
office is in the back of the large lab in Edmunds 218) for assistance.
### 1.2 (optional) installing Python and PyCharm
You are welcome to do these projects entirely on lab machines,
entirely on your own machine, or some combination (e.g. part 1
on lab machines and part 2 on your own personal machine).
If you want to use your own personal machine, you will need to
download and install Python 3.7 and PyCharm.
The latest Python interpreter can be downloaded from
[www.python.org/downloads] (https://www.python.org/downloads)
(with packages for
[Windows](https://www.python.org/downloads/windows/) and
[Mac OS X](https://www.python.org/downloads/mac-osx/)).
You should select the latest distribution of Python 3.7,
and install it after it is down-loaded.
If you are running Linux, there is a pretty good chance
that there is already a Python 3.7 package in your
standard package repository.
If you are running Ubuntu, the commands would be:
```
sudo apt-get update
sudo apt-get -y install python3.7
```
For RedHat users, the corresponding command might be:
```
yum install python3.7
```
PyCharm can be downloaded by going to
[JetBrains](https://www.jetbrains.com/pycharm/download/)
and selecting your platform (Windows, macOS or Linux).
Make sure you download the (free, open-source)
Community Edition.
It might be best if you attempt to do this before coming to the lab,
so that we can help you more quickly to resolve any problems.
### 1.3 Starting PyCharm
PyCharm will, by default, try to maintain all of your projects under a single folder.
Before starting PyCharm for the first time you should create a new workspace folder.
We suggest that you create a new folder on your desktop named `CSCI051p-Workspace`.
Launching PyCharm
- On a Mac you can start PyCharm by clicking the `PC` icon on your menu-bar.
- On an Ubuntu system you can use the Application launcher search function to find it,
and then add it to your menu-bar.
- On a Windows system you can click `Start` and search the name of `PyCharm` to find it,
and you can drag it to generate a shortcut or pin it to the start menu.
### 1.4 Creating a new project
After starting PyCharm you can can accept the defaults and, eventually,
should get to a screen that invites you to select ***Create New Project***.
Go ahead and create the project, making sure that the location of the
project is a new sub-folder (e.g. `Setup`) in the
`CSCI051p-Workspace` you just created on your Desktop.
***WARNINGS for new project creation***
1. make sure you put the new project in the Workspace folder you just
created. Not in the default location, which will be very difficult
for you to find.
2. do not check-off the option to
create a run script. You do not need this, and it will require
you to enter an administrator password before the project can
be created.
3. use the default Python
tools. Do not check the option to create a virtual
environment.
You should now be looking at the main screen:
- a menu bar at the top
- a (nearly empty at this point) list of projects and files on the left
- a main window
- a list of screen selections on the bottom
If the list of screens on the bottom does not include `Python Console`
select (from the top menu bar) `view->Tool Windows->Python Console`.
This will open a frame at the bottom of the window which is running the
Python interpreter. As you saw in lecture, the interpreter gives you the
prompt `>>>`, at which you can directly type Python statements.
### 1.5 Editing and running a Python program
Download the [Setup.py](Setup.py) starter file for this
assignment, and copy it into the (recently created) `CSCI051p-Workspace/Setup`
folder. Then ask PyCharm to re-scan that folder by clicking the triangle next to
that folder (on the left-side list) to close and re-open it. The newly added
`Setup.py` should now be visible. If you double-click it (in the left-side list),
that file should appear in the main editing window.
The easiest way to Run a program that you are editing is to place the cursor in
the file editing window and right-click. One of the options will be `Run`
(and the name of the currently selected file). If you select this option,
the Python interpreter will execute the selected program and display the output
(in a `Run` window) at the bottom of the screen.
If you have run multiple programs, you can choose which one you want to run
with a selector and buttons near the top right of the screen:
- a drop-down list contains the names of each previously run file.
- a triangular run button will re-run the selected program.
You can also select `Run->Run` from the top
menu-bar and then choose (from the supplied list of previously run programs)
which one you want to run.
#### 1.5.1 Changing the `print` statement
Edit the supplied starter and change the `print` statement to print out
the class, your name, and the assignment number. Sample output might
look like
```
CS051P Riley Greatstudent, Assignment #0: Setup
```
Run the program and confirm that it now prints out the correct information.
#### Checking In
If you are doing this assignment in the lab, call over an instructor
or TA to check your output and code. If you have successfully gotten
PyCharm started and made and run the above changes, they will award
your points for Part 1.
If you are not doing this assignment in the lab, take a screen-shot
of the PyCharm window that shows your edited program and the output
from running it, and e-mail it to your Instructor.
## Part 2: Commenting, Feedback and Submission
### 2.1 Commenting your code
Code is written both for the machine and for people (both for other
people such as TAs and for future-you). As a result, it is critical
that you comment your code both for this class and for anything else
you write. The following are two ways to comment code in Python;
you should become comfortable with both.
- Any text that comes after a `#` and before a newline is ignored
by the interpreter. This can be used to introduce a short
single-line comment.
- Multi-line (or block) comments are enclosed in triple quotes.
Examples of both can be seen at the beginning of the supplied starter.
Change the block comment at the beginning of the file to have
your name.
After you have made these changes, run the program again to make
sure you have not made any mistakes.
A fuller discussion of commenting and code style can be found in the
[Python Coding Style Guidelines](../../python_style.html).
### 2.2 Feedback
Create a file named `feedback.txt` (in the same folder) that answers the usual questions:
1. How long did you spend on this assignment?
2. Any comments or feedback? Things you found interesting? Things you found
challenging? Things you found boring?
## Submission
For this lab you are required to submit two files:
- `Setup.py` your updated and commented version of the supplied starter file.
- `feedback.txt` a text file containing your feedback for this assignment.
These should be submitted using [submit.cs.pomona.edu](http://submit.cs.pomona.edu)
as described in the general [submission instructions](../../submit.html).
Note that you will lose credit if your submitted files are incorrectly named.
## Note on Academic Honesty
You are encouraged to demonstrate your working code to each other.
You are even encouraged to be inspired by what other people have done
in order to make your own program even more amazing. However, if you
do so, you *must* acknowledge them (both name and what exact
idea you used from them) in that multi-line comment at the top of your
program. Note that you also must acknowledge any other sources that
you are inspired by (e.g. a submission based on HAL 9000 from Arthur
C. Clarke's novel `2001: A Space Odyssey`). From experience,
we know that dealing with academic honesty cases is extremely
stressful for everyone involved. Please don't let it come to that.
## Grade Point Allocations
| Part | Feature | Value |
|-----------|-------------------------------------------|-----|
| Lab | Importing starter into PyCharm project | 5 |
| | | |
| Execution | prints course, name and assignment | 5 |
| Execution | no errors | 5 |
| | | |
| Style | Correctly named file | 2 |
| Style | file-level block comment | 2 |
| | | |
| Feedback | Completed feedback file submitted | 1 |