##### Copyright 2020 The Cirq Developers

```
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
```

# Notebook template

    View on QuantumLib

    Run in Google Colab

    View source on GitHub

    Download notebook

```
try:
    import cirq
except ImportError:
    print("installing cirq...")
    !pip install --quiet cirq
    print("installed cirq.")
```

## Make a copy of this template

You will need to have access to Quantum Computing Service before running this colab.

This notebook can serve as a starter kit for you to run programs on Google's quantum hardware.  You can download it using the directions below, open it in colab (or Jupyter), and modify it to begin your experiments.

## How to download iPython notebooks from GitHub

You can retrieve iPython notebooks in the Cirq repository by
going to the [docs/ directory](https://github.com/quantumlib/Cirq/tree/master/docs).  For instance, this Colab template is found [here](https://github.com/quantumlib/Cirq/blob/master/docs/tutorials/google/colab.ipynb). Select the file that you would like to download and then click the *Raw* button in the upper-right part of the window:

This will show the entire file contents.  Right-click and select *Save as* to save this file to your computer.  Make sure to save to a file with a `.ipynb` extension (you may need to select *All files* from the format dropdown instead of *text*). You can also get to this Colab's [raw content directly](https://raw.githubusercontent.com/quantumlib/Cirq/master/docs/tutorials/google/colab.ipynb)

You can also retrieve the entire Cirq repository by running the following command in a terminal that has `git` installed:

```
git checkout https://github.com/quantumlib/Cirq.git
```

## How to open Google Colab

You can open a new Colab notebook from your Google Drive window or by visiting the [Colab site](https://colab.research.google.com/notebooks/intro.ipynb).  From the Colaboratory site, you can use the menu to upload an iPython notebook:

This will upload the ipynb file that you downloaded before.  You can now run all the commands, modify it to suit your goals, and share it with others.

### More Documentation Links

* [Quantum Engine concepts](../../google/concepts.md)
* [Quantum Engine documentation](../../google/engine.md)
* [Cirq documentation](https://cirq.readthedocs.io)
* [Colab documentation](https://colab.research.google.com/notebooks/welcome.ipynb)

## Authenticate and install Cirq

For details of authentication and installation, please see [go/quantum-engine-quickstart](http://go/quantum-engine-quickstart).

Note:  The below code will install the latest stable release of cirq.  If you need the latest and greatest features and don't mind if a few things aren't quite working correctly, you can install `cirq-unstable` instead of `cirq` to get the most up-to-date features of cirq.

1. Enter the Cloud project ID you'd like to use in the `project_id` field.
2. Then run the cell below (and go through the auth flow for access to the project id you entered).

```
# The Google Cloud Project id to use.
project_id = '' #@param {type:"string"}

if project_id == '':
    raise Exception("Please setup project_id in this cell!")

def setup_auth():
  """Runs the user through the Colab OAuth process.

  Sets the local Application Default Credentials. For more information on on
  using Application Default Credentials see
  https://cloud.google.com/docs/authentication/production
  """
  from google.colab import auth
  auth.authenticate_user(clear_output=False)

print("Getting OAuth2 credentials.")
print("Press enter after entering the verification code.")
setup_auth()
print("Authentication complete.")
```

    Getting OAuth2 credentials.
    Press enter after entering the verification code.
    Authentication complete.
    Requirement already satisfied: cirq in /usr/local/lib/python3.6/dist-packages (0.8.2)
    Requirement already satisfied: freezegun~=0.3.15 in /usr/local/lib/python3.6/dist-packages (from cirq) (0.3.15)
    Requirement already satisfied: google-api-core[grpc]<2.0.0dev,>=1.14.0 in /usr/local/lib/python3.6/dist-packages (from cirq) (1.16.0)
    Requirement already satisfied: typing-extensions in /usr/local/lib/python3.6/dist-packages (from cirq) (3.7.4.3)
    Requirement already satisfied: dataclasses; python_version < "3.7" in /usr/local/lib/python3.6/dist-packages (from cirq) (0.7)
    Requirement already satisfied: sympy in /usr/local/lib/python3.6/dist-packages (from cirq) (1.1.1)
    Requirement already satisfied: networkx~=2.4 in /usr/local/lib/python3.6/dist-packages (from cirq) (2.5)
    Requirement already satisfied: protobuf~=3.12.0 in /usr/local/lib/python3.6/dist-packages (from cirq) (3.12.4)
    Requirement already satisfied: sortedcontainers~=2.0 in /usr/local/lib/python3.6/dist-packages (from cirq) (2.2.2)
    Requirement already satisfied: scipy in /usr/local/lib/python3.6/dist-packages (from cirq) (1.4.1)
    Requirement already satisfied: numpy~=1.16 in /usr/local/lib/python3.6/dist-packages (from cirq) (1.18.5)
    Requirement already satisfied: requests~=2.18 in /usr/local/lib/python3.6/dist-packages (from cirq) (2.23.0)
    Requirement already satisfied: matplotlib~=3.0 in /usr/local/lib/python3.6/dist-packages (from cirq) (3.2.2)
    Requirement already satisfied: pandas in /usr/local/lib/python3.6/dist-packages (from cirq) (1.0.5)
    Requirement already satisfied: python-dateutil!=2.0,>=1.0 in /usr/local/lib/python3.6/dist-packages (from freezegun~=0.3.15->cirq) (2.8.1)
    Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from freezegun~=0.3.15->cirq) (1.15.0)
    Requirement already satisfied: setuptools>=34.0.0 in /usr/local/lib/python3.6/dist-packages (from google-api-core[grpc]<2.0.0dev,>=1.14.0->cirq) (49.6.0)
    Requirement already satisfied: pytz in /usr/local/lib/python3.6/dist-packages (from google-api-core[grpc]<2.0.0dev,>=1.14.0->cirq) (2018.9)
    Requirement already satisfied: googleapis-common-protos<2.0dev,>=1.6.0 in /usr/local/lib/python3.6/dist-packages (from google-api-core[grpc]<2.0.0dev,>=1.14.0->cirq) (1.52.0)
    Requirement already satisfied: google-auth<2.0dev,>=0.4.0 in /usr/local/lib/python3.6/dist-packages (from google-api-core[grpc]<2.0.0dev,>=1.14.0->cirq) (1.17.2)
    Requirement already satisfied: grpcio<2.0dev,>=1.8.2; extra == "grpc" in /usr/local/lib/python3.6/dist-packages (from google-api-core[grpc]<2.0.0dev,>=1.14.0->cirq) (1.31.0)
    Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.6/dist-packages (from sympy->cirq) (1.1.0)
    Requirement already satisfied: decorator>=4.3.0 in /usr/local/lib/python3.6/dist-packages (from networkx~=2.4->cirq) (4.4.2)
    Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests~=2.18->cirq) (2.10)
    Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests~=2.18->cirq) (1.24.3)
    Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests~=2.18->cirq) (3.0.4)
    Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests~=2.18->cirq) (2020.6.20)
    Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib~=3.0->cirq) (0.10.0)
    Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib~=3.0->cirq) (2.4.7)
    Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib~=3.0->cirq) (1.2.0)
    Requirement already satisfied: rsa<5,>=3.1.4; python_version >= "3" in /usr/local/lib/python3.6/dist-packages (from google-auth<2.0dev,>=0.4.0->google-api-core[grpc]<2.0.0dev,>=1.14.0->cirq) (4.6)
    Requirement already satisfied: cachetools<5.0,>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from google-auth<2.0dev,>=0.4.0->google-api-core[grpc]<2.0.0dev,>=1.14.0->cirq) (4.1.1)
    Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.6/dist-packages (from google-auth<2.0dev,>=0.4.0->google-api-core[grpc]<2.0.0dev,>=1.14.0->cirq) (0.2.8)
    Requirement already satisfied: pyasn1>=0.1.3 in /usr/local/lib/python3.6/dist-packages (from rsa<5,>=3.1.4; python_version >= "3"->google-auth<2.0dev,>=0.4.0->google-api-core[grpc]<2.0.0dev,>=1.14.0->cirq) (0.4.8)
    Cirq installed.

## Create an Engine variable

The following creates and engine variable which can be used to run programs under the project ID you entered above.

```
import cirq

# Create an Engine object to use, providing the project id and the args
# used for authentication (produced by running the authentication above).
engine = cirq.google.Engine(project_id=project_id)
```

## Example

```
# A simple example.
q = cirq.GridQubit(5, 2)
circuit = cirq.Circuit(cirq.X(q)**0.5, cirq.measure(q, key='m'))

job = engine.run_sweep(
    program=circuit,
    repetitions=10000,
    processor_ids=['rainbow'],
    gate_set=cirq.google.SYC_GATESET)

results = [str(int(b)) for b in job.results()[0].measurements['m'][:, 0]]
print('Success!  Results:')
print(''.join(results))
```

    Success!  Results:
    0000001111010100111111000100000000011100001000000011110011101011101101100000101000000110010110011100001001000110001110100101010010101100011010110000010001011001111001111001110011111001100011110110001001101010000000000111101101010110101010011011011111110010111010000010001000101110101100111111111101110100100100000011110010010000110111100111010010101111010001111100011100100101010011111011100000000100100001001100110001000101000011010101010111110001000000011100100000001011011111111001001011000001100110101000000001100110000111000100110101110111101010100110001101001000010110011001011010000111111000111010101111100101100001011101100101000110001100001100010001001001110010000010001011111101101101111011101101100010110001000111001010101001011111011111100011001110001110010111000011010011101101000011100111011000001001010101010010001101011010101011001001010001000111100101000011000101011011110111011101001011001001011011001101111010010011110010011101011011010111001110110101010101010101010001100101000001000101101001010000101110101011011111101010001011111010111110011101111111010100000001100000001100100011001011110111011111110011101010111000011101100111111101100001111100001110100100001010011001110111010000011101110011010001111011110101010011010111011001000101111010000110000111010111110001101011010010100010111111100001011111000001010000001001101100110011001100001000101101001100101011101100011011000111100111000001001100001110100010110011101001111101011000100111010001111001111000110000101001000100010110110001011111001100110101110001110110101101010001010101110100100110100000101101000101010011000110101010101011110111011111110010111011111100000001000000011110101010100111110000010001000101000111011001100100011001101101010000101010001100000001010001110110000000000111100110000010101100001000101110101100010110000010101000110110100010110101001001010010001010111010001001100000000011101110110010111100000000010011001010010010111111010100001011010100101001001110101100000001011001100011100111110011001101111000001001101111100111010100111111101000011100100110111010100010010000001101111111100101111101000101101010000010010100000100111000000110101111101000101001010010001111101000000001011011000111110001111100111010000110000100000110010101110011010100110010010111111010101100101101001111001001000000000100011111000101101001011010110010100100000011001111100111101111111011010110010000111001000110000011001111111010010010100110000011100101011001000111011010101000001011100010001011001111001101000111011000110110001001110010000010111010110100100110000010011101001000100010010011100000010010110100100011011010111000110110110000001001011000000000100111000101110010110001111001001111001011011110010110010101010001100010101000100000110111010111001111000111000010000100101011001001100111100011111000001010110011110111000101000010000110011010110110101110100000101011011001011001110011001001101010001000000111110000101100001100101000110000011110001110000101001001100010101010000000100101100001101001111001001101000010100001011110011100000100000000100010101100111101100011101101010100010110000101010011011101011010100110111100110011001011001000110100001000100010111011011110111011011110100010010011100001011001111001010111000000010110110100001010111010000111110101000000110101100110001010001101110101001110100110110110011111100111101111111001010011011001101111000000110110111110111000010001011001011011010110000000010010100101000110110000100011011010011110100010101101101001001001100001100001011000110011011011110100100000010001011011111000010110010111010011110011110010000101111011100010010011101011110000101010010000011001110101111000001011110010111110001110110100101001001100000011001010010100011101001100110111000001011111011010000111100010111100000011000110001111010100000111000101100000011100100101111100101111100111011110100110011100011110100111010000010111000110100011001000010011100101111010010100110100100011101100111001100101111111110101101001010111100000110010000111100010100100110001010000010011101110111010110010100000110001111100001001000100001010001010110101110110110111100101110001110010010001010110000001000101010111110001100011111011100010110111011000000010101110111101100110000010000000010100111110011000010000001010101111010100000110001001011000010101111100001111110001101100011110110010010110011110110010001011100010010000000010000101010010111101001010101011001011110100000101111100111010010110010001110001010101000111001101110011100000010101101011000100010110011011011111100010110111110100111111101100001100000000000101000101011100111000000100110000010110110010001111000011000101110000010101110011011000010111110111110101101000000100000110101010001000100100000010000101010000011010001000001111001001010011101101001001100100101011111011010100101010001011110111110011101100001010111111110110111010000011111100001101101000010111010000110001111000101110010110110101110000100000111101001101100111100000110100011101101111011111010010001110010011011110101101100100001001000110100110110001010111011101101100101101000111001000110111101000000001011000100110100010011001000111110010101110010010011011011011001111110010000111011011101010001011011000011010111011100001011000111100101000011010101010010001000010000100001000101100111111111110000111110010011001000110110111010000000110110100100111101101011001111110011010100000111000100100110110000000001110110010000010100010100101001000001101101100101001111101000111100001111110011110001000110000011011100100110100000010111011011000000011000000001011101010110100111101001101100100001111000011101110011001111111011101011000100010011001101010100110000001100111000001011001010110100111001101111101101000100111110001111100001110010110000000100101011010111001001100011101110111011100111011111111111111010010101100111111100101011101101011011010111110011011110111011111100110101010000000000101111000010100100100000100001110011010011001001110111111110001101010001010000010110111111111011010000110101001010111111110110111000111011000101100001000011010111010010000111110110100110010111000011011100000110011000110100011111100110000101101111101001100101001010101001011111100010110110000100110111110010111100011010110000011001100111010010000111111011000010110100111111101000101101100110000001010011000011111101010000000010011101101101111000101100010100001100011011100001101111101011101010110001110000101011011100010100110011001100110001100001101001000000010101100001000000110101110111000110100100101000001110110111001000001101100011011000010101110011100001111000011101011001011010100001101101011111001000101001011101000010111011000101011101110110100011110111101110110011101111010111010111001001101110001011000100011101000111000001000000100100000101000100001001010101110111010010011000100000010000111101011000010100100111001111101111011001110101000000100001111111000111100100011101111111000001111111101100000110010001110110001111010100010000000010000010101010010101000001001000000011001101100001110111010001000101011001010000000100111101001111010010001011011101011011011101110100000110110001100001010010111000111010010011110010001001010001001000011110000001000001111001101001111011011100010110010010101000001011000000100000101000111110010001000100000000110111100001011100010011100001011100110100001000010101101010100001000000100100010101001000101110110111010111111000110000100010000011110100100111010100000011111101010110100110110100001000001001001010101011010101011110011111000011000000111101110100000100101111100111110110000100110100000011111110111110100001011010111010000100101010101110001100100101000101101101001011101010101100111001001101001000110101111111001111011110101011101001110100000010010001101101100000010110000011001100001110110010100000000011110111100000100001101011001100110110000001001000001101111001101101111001110011101101101010001101100110111110011110010001000110110010100100010100111000000100010111011100100110100100110111000110001010010000110000001101000010100011101110010110101100001101001101000000100100010000010000011110110101100000011110010101010010001100110101001100101000101100010101001010000111000111000000000001001100100110001111000110100001000000010001110011011001110000011001000011101010011110000101001101111100110000111110101111111111101011100101011001001010101101001100110110111000111110111011101000011001100101010111101100111010001001000001011001101101111110001001111111111110001000100011100101100110110101101100110110010110011111001101001011011111110001011110110000100010000101011110011001000100010100011101111100010011011010011100111110111000111100110000010011100111011100011001011001101101011001000001001010011101111010000101011010100011010011001111011010001111010010111001111000001000001111100100010110001000100011011110001010011101000110000100110010111110111110011000101001000111000001100001110010000011100010001111100011001110011100001100011010010000001000001100010100100110101001101110011001001010100011010110011111010101100111110010011100101101111001110001011001000101101100111010000100111101010101010100001100011001101011111111110010001111100111001001110010101100111001010000001000100000111101110111001110111100100110101000110000001100000101001010001111000001110110100000011100011011100011011100101010100110011111110110011110100100111100110110100111010100001011101010001000010011010011101010001010101000100011111110001010000000100100111101110100000100100110100000101001111011011011110011111101001011100010111110110100011001100000101000110100101101011001010111100000000111010101011101110101100100101001001111010001111100101010011011000101000111100010010010000001111001001100011110001000110011010110110100100111011100111010110111010110011010101010111100110000101101111101110010001010011000010111001110110000100100101010001001010110110001001001011001000010100111100010110110101000111100110010110001010010010000110010101111000010001100111010100010111100110000000010001101001011100110001011000100101000011101000010110100001110011010101111011101111110110011111111000111010010010100010011100100100100011111111011111110100110001100110


# Homework 3
### Due Date:  Tuesday, September 20th at 11:59 PM

---
## Problem 1:  `Git` and recovering from a mistake
You will do this problem in the Jupyter notebook so I can see your output.  Once again, you will work with your playground repository.

**NOTE:** At the beginning of each cell, you MUST type `%%bash`.  If you don't do that then you will not be able to work with the necessary bash commands.

Follow the following steps for this problem:

1. First cell:
  1. Type `cd /tmp` to enter the temporary directory
  2. git clone url_to_your_playground_repo
2. Second cell:
  1. Go into your local `playground` directory (`cd /tmp/playground`)
  2. Type `git pull origin mybranch1`
  3. `ls`
3. Third cell:
  1. Go into your local `playground` directory (`cd /tmp/playground`)
  2. Type `git status`
4. Fourth cell:
  1. Go into your local `playground` directory (`cd /tmp/playground`)
  2. Type `git reset --hard origin/master`
  3. `ls`
5. Fifth cell:
  1. Go into your local `playground` directory (`cd /tmp/playground`)
  2. Type `git status`

The whole point of this problem was to show you how to get your local repo back to an earlier state.  In this exercise, you accidentally merged something to `master` that you didn't want.  Rather than starting to delete things all over the place, you can simply reset your `HEAD` to a previous commit.

```bash
%%bash
cd /tmp
rm -rf playground #remove if it exists
git clone https://github.com/syj19950301/playground.git
```

    Cloning into 'playground'...

```bash
%%bash
cd /tmp/playground
git pull origin mybranch1
ls
```

    Merge made by the 'recursive' strategy.
     books.md | 1 +
     1 file changed, 1 insertion(+)
     create mode 100644 books.md
    README.md
    books.md
    feature.txt
    intro.md
    world.md

    From https://github.com/syj19950301/playground
     * branch            mybranch1  -> FETCH_HEAD

```bash
%%bash
cd /tmp/playground
git status
```

    On branch master
    Your branch is ahead of 'origin/master' by 2 commits.
      (use "git push" to publish your local commits)
    nothing to commit, working directory clean

```bash
%%bash
cd /tmp/playground
git reset --hard origin/master
ls
```

    HEAD is now at 07a6807 HW3 Problem 2 practice
    README.md
    feature.txt
    intro.md
    world.md

```bash
%%bash
cd /tmp/playground
git status
```

    On branch master
    Your branch is up-to-date with 'origin/master'.
    nothing to commit, working directory clean

## Problem 2:  `Git` and checking out a single file
Sometimes you don't want to merge an entire branch from the upstream but just one file from it. There is a direct use case for such a situation. Suppose I've made an error in this homework (or a lecture) and want to correct it. I fix the mistake in the upstream repo. In the meantime you have edited some other files and you really don't want to manually ignore my older copies of those files. Rather, you want to fix just one file from this new branch. This is how you do it.

As usual, be sure to type in `%%bash` before you write any `bash` commands in a cell.

**Note:** The steps below assume that you have already cloned the `playground` repo in this notebook.

1. First cell:
  1. Go into the `playground` repo and fetch the changes from the master branch of the `course` remote.
2. Second cell:
  1. `git checkout course/master -- README.md`.  The `--` means that `README.md` is a file (as opposed to a `branch`).
  2. `cat README.md`.  This just looks at the updated file.
3. Third cell:
  1. `git status`
  2. Commit the changes to your local repo with an appropriate commit message.
  3. `git status`
  4. Push the changes to your remote repo.

```bash
%%bash
cd /tmp/playground
git remote add course https://github.com/IACS-CS-207/playground.git
git fetch course
```

    From https://github.com/IACS-CS-207/playground
     * [new branch]      master     -> course/master

```bash
%%bash
cd /tmp/playground
git checkout course/master -- README.md
cat README.md
```

    # Playground Repo

    For practicing.

```bash
%%bash
cd /tmp/playground
git status
git add README.md
git commit -m "HW3 Problem 2 practice"
git push
```

    On branch master
    Your branch is up-to-date with 'origin/master'.
    nothing to commit, working directory clean
    On branch master
    Your branch is up-to-date with 'origin/master'.
    nothing to commit, working directory clean

    warning: push.default is unset; its implicit value has changed in
    Git 2.0 from 'matching' to 'simple'. To squelch this message
    and maintain the traditional behavior, use:

      git config --global push.default matching

    To squelch this message and adopt the new behavior now, use:

      git config --global push.default simple

    When push.default is set to 'matching', git will push local branches
    to the remote branches that already exist with the same name.

    Since Git 2.0, Git defaults to the more conservative 'simple'
    behavior, which only pushes the current branch to the corresponding
    remote branch that 'git pull' uses to update the current branch.

    See 'git help config' and search for 'push.default' for further information.
    (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
    'current' instead of 'simple' if you sometimes use older versions of Git)

    Everything up-to-date

## Problem 3
This problem is related to the Lecture 4 exercises.
1. Open the `languages.txt` file.  This file contains all the languages that students listed as their primary language in the course survey.
2. Load the language strings from the file into a list.
3. Use the `Counter` method from the `collections` library to count the number of occurrences of each element of the list.
  + **NOTE:**  It is not necessary to use the `most_common()` method here.
4. Create a bar plot to display the frequency of each language.  Be sure to label the x-axis!
  + Remember, to create plots in the notebook you must put the line `%matplotlib inline` at the beginning of your notebook.
  + Be sure to import matplotlib:  `import matplotlib.pyplot as plt`.
  + To generate the bar plot write `plt.bar(x_coords, freqs)`.  You need to define `x_coords` and `freqs`.
  + **Hint:** You may want to use the `numpy` `arange` function to create `x_coords`.  Remember, `x_coords` is the x-axis and it should have points for each distinct language.
  + **Hint:** To get `freqs`, you may want to use the `values()` method on your result from step 3.  That is, `freqs = result_from_3.values()`.
  + **Hint:** To label the x-axis you should use `plt.xticks(x_coords, labels)` where labels can be accessed through the `keys()` method on your result from step 3.

```python
import collections
import numpy as np
import os
# cwd = os.getcwd()
# print(cwd)
f = open("/Users/shenyijun/Desktop/GitHub/cs207_yijun_shen/lectures/L4/languages.txt", "r")
languages = f.read()
f.close()
```

```python
languages_list = languages.split('\n')[:-1]
print(languages_list)
```

    ['Python', 'C++', 'Java', 'Python', 'Python', 'Python', 'Python', 'C++', 'Python', 'C', 'Other', 'Python', 'Python', 'Python', 'C++', 'Other', 'Python', 'Python', 'Python', 'Java', 'Python', 'Python', 'C#', 'Python', 'SQL', 'C++', 'C++', 'Python', 'Java', 'Java', 'Java', 'Python', 'Python', 'Python', 'SQL', 'Java', 'Python', 'Python', 'C++', 'Java', 'Python', 'Python', 'VB', 'Python', 'Python']

```python
languages_counter = collections.Counter(languages_list)
print(languages_counter)
```

    Counter({'Python': 25, 'Java': 7, 'C++': 6, 'Other': 2, 'SQL': 2, 'C': 1, 'C#': 1, 'VB': 1})

```python
%matplotlib inline
import matplotlib.pyplot as plt
freqs = languages_counter.values()
x_coords = np.arange(1,9)
plt.bar(x_coords,freqs)
labels = languages_counter.keys()
plt.xticks(x_coords,labels)
```

---
## Problem 4
In chemical kinetics, the reaction rate coefficient for a given reaction depends on the temperature of the system.  The functional relationship between the reaction rate coefficient and temperature is given by the Arrhenius rate:
\begin{align}
k\left(T\right) = A T^{b}\exp\left(-\frac{E}{RT}\right)
\end{align}
where $A$, $b$, and $E$ are parameters, $R = 8.314 \dfrac{\textrm{J}}{\textrm{mol} \textrm{ K}}$  is the universal gas constant, and $T$ is the temperature.

Write a function which returns $k\left(T\right)$ given $A$, $b$, $E$, and $T$.  Here are a few requirements:
* The function should test for exceptions where necessary.
* Pass the parameters $A$, $b$, and $E$ in as a list.
* Make $R$ a keyword argument to the function.

```python
import math
def reaction_rate(AbE, T, R=8.314):
    if T <= 0:
        print("Warning: Temperature must be greater than zero")
    else:
        return AbE[0]*(T**AbE[1])*(math.exp(AbE[2]/(R*T)))
```

# ---
## Problem 5
Using `numpy` arrays, plot $k\left(T\right)$ for $T\in\left(0, 5000\right]$ for three different sets of parameters $\left\{A, b, E\right\}$.  Make sure all three lines are on the same figure and be sure to label each line.  You may use the function from Problem 2.  You may want to play with the parameters a little bit to get some nice curves but you won't lose points for ugly curves either (as long as they're correct!).

```python
case1 = [1, 1, 3]
case2 = [2, 0.1, 5]
case3 = [10, 0.5, 10]
```

```python
T_coords = np.array(range(1,5001))
k1 = np.array([0] * T_coords.shape[0])
k2 = np.array([0] * T_coords.shape[0])
k3 = np.array([0] * T_coords.shape[0])
for i in T_coords:
    k1[i-1] = (reaction_rate(case1, i))
    k2[i-1] = (reaction_rate(case2, i))
    k3[i-1] = (reaction_rate(case3, i))

plt.ylabel("Reaction Coefficient Rate")
plt.xlabel("Temperature")
plt.plot(T_coords,k1, label="case1")
plt.plot(T_coords,k2, label="case2")
plt.plot(T_coords,k3, label="case3")
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
plt.show()
```

```python

```