{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Grader\n", "\n", "**Note:** These grading exercises are being validated against the `test_challenge` in the grading service." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using markdown cells\n", "\n", "\n", "The following examples use the `q-code-exercise` syntax in a markdown cell with `grader-import` and `grader-function` attributes:\n", "\n", "\n", "\n", "\n", "```python\n", "# set variable to a prime number\n", "\n", "prime_num = 317\n", "\n", "```\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "```python\n", "from qiskit import QuantumCircuit\n", "\n", "qc = QuantumCircuit(2)\n", "\n", "qc.x(0) # Do X-gate on qubit 0\n", "qc.y(1) # Do Y-gate on qubit 1\n", "qc.z(1) # Do Z-gate on qubit 1\n", "\n", "qc.draw()\n", "```\n", "\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following examples use the `q-code-exercise` syntax in a markdown cell with `grader-id` and `grader-answer` attributes\n", "\n", "\n", "\n", "\n", "```python\n", "# set variable to a string of vowels\n", "\n", "vowels = 'aeauioo'\n", "\n", "```\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "```python\n", "from qiskit import QuantumCircuit\n", "\n", "qc = QuantumCircuit(2)\n", "\n", "qc.x(0) # Do X-gate on qubit 0\n", "qc.y(1) # Do Y-gate on qubit 1\n", "qc.z(1) # Do Z-gate on qubit 1\n", "\n", "qc.draw()\n", "```\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using code cells\n", "\n", "The following examples use a code cell with `grader_import` and `grader_function` in the cell metadata\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "goals": [ { "id": "widgets-grader-cell-1" } ], "grader_function": "grade_ex1d(vowels2)", "grader_import": "from qc_grader.challenges.test_challenge import grade_ex1d" }, "outputs": [], "source": [ "# set variable to a string of vowels\n", "\n", "vowels2 = 'uieaoeauio'\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "goals": [ { "id": "widgets-grader-cell-2" } ], "grader_function": "grade_ex2a(qc2)", "grader_import": "from qc_grader.challenges.test_challenge import grade_ex2a" }, "outputs": [], "source": [ "from qiskit import QuantumCircuit\n", "\n", "qc2 = QuantumCircuit(2)\n", "\n", "qc2.x(0) # Do X-gate on qubit 0\n", "qc2.y(1) # Do Y-gate on qubit 1\n", "qc2.z(1) # Do Z-gate on qubit 1\n", "\n", "qc2.draw()\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following examples use a code cell with `grader_id` and `grader_answer` in the cell metadata\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "goals": [ { "id": "widgets-grader-cell-3" } ], "grader_answer": "prime_num_2", "grader_id": "test_challenge/test-prime" }, "outputs": [], "source": [ "# set variable to a prime number\n", "\n", "prime_num_2 = 29\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "goals": [ { "id": "widgets-grader-cell-4" } ], "grader_answer": "qc2", "grader_id": "test_challenge/test-circuit" }, "outputs": [], "source": [ "from qiskit import QuantumCircuit\n", "\n", "qc2 = QuantumCircuit(2)\n", "\n", "qc2.x(0) # Do X-gate on qubit 0\n", "qc2.y(1) # Do Y-gate on qubit 1\n", "qc2.z(1) # Do Z-gate on qubit 1\n", "\n", "qc2.draw()\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9" } }, "nbformat": 4, "nbformat_minor": 4 }