# Numerical Answers with Python
This page is specific to the **Python** questions (**without coding**). The objectives are:
- Use the necessary Python function in the `server.py` to generate the solutions, and grade the questions
- Specify the randomized variables in the `server.py`
- Specify the specific files (e.g., **figure**) in the `server.py`
## Overview
The easiest way to create a Python question (without coding) is by copying an existing question (either Python or R), and change certain files. Then you don't need to create the [UUID](https://www.uuidgenerator.net/) by yourself.
Note: Each UUID will be assigned to a question only.
## Step 1: Copy a question
* Follow the Step 1 to Step 4 in the **[Routine work](https://pl-cee202-docs.readthedocs.io/en/latest/page/setup.html#routine-work)**. Then click **PrarieLearn** logo (next to **Admin**) in the upper left.
* Click a course such as **`CEE 202: Engineering Risk & Uncertainty`** in the `Courses` (not `Course instances`) list.
* Click the `Questions` (next to `Issues`) on the top line.
* Find a question you want to copy (for example: `AS4_Prob5_2020_AngTang`).
* Click `Settings` between `Preview` and `Statistics`.
* Click `Make a copy of this question`
* Click `Change QID`
## Step 2: Modify the questions
Before you modifying the question, I strongly suggest creating a **spreadsheet** to keep track of the questions (including title, topic, tags) and corresponding UUID.
Note: Each question folder contain the following files
| Folder/File Name | Usage |
| -------------------------------- | ------------------------------------------------------------ |
| info.json | The information of the question such as title, topic, tags, and uuid. |
| question.html | The main body of the question |
| server.py | The solution to the question, but it also species |
| clientFilesQuestion | Save the figures for the question. |
| clientFilesQuestion
This is the problem statement.
(a) Determine the probability that the settlement will exceed ${{params.a}}$ cm.
/dist.png | The figure needes to be added to the question |
### info.json
* Click `Edit` under `Settings`
* Define the `title`, `topic`, `tags`, and `type`
### server.py
* Click `Files` (under `PrairieLearn` in the upper left) → `Edit` the `server.py`, then you need to finish the following tasks:
```python
import rpy2.robjects as robjects
import prairielearn as pl
import numpy as np
from numpy import arange
from numpy.random import choice
def generate(data):
# start to code your solution
## "a" could be 3.8, 3.9, 4.0, 4.1, 4.2
a = choice(arange(3.8,4.3,0.1),1)
answer_a = a+1
# here is the end of your solution
# Setup output
data['correct_answers']["answer_a"] = answer_a
# Setup randomized variables
data["params"]["a"] = a
# define the figure name
image_name = "dist.png"
data["params"]["image"] = image_name
```
* import the necessary packages at the beginning
* Change the randomized variable using `a=choice(arange(start,end+interval,interval),1)`
Note: `a` corresponds to `${{params.a}}$`, `answer_a` corresponds to `answers-name="answer_a"` in the `question.html`
* Change the `image_name` (if you have figure(s))
### question.html
* Click `Files` (under `PrairieLearn` in the upper left) → `Edit` the `question.html`, then you need to finish the following tasks:
```html
The answer is: (0.XX)