# Exercise - Collect input

## Creating reusable applications

Having a program with hard-coded values limits its flexibility. Your first officer likes the program you build to convert parsecs to lightyears, but wants the ability to specify a value for parsecs. She wants you to create a program which can accept user input.&#x20;

This exercise is broken into a series of steps. For each step you will be presented with the goal for the step, followed by an empty cell. Enter your Python into the cell and run it. The solution for each step will follow each cell.&#x20;

## Accepting user input

In the prior exercise you created code to convert parsecs to lightyears and display the results, which looked like the following:

```python
parsecs = 11
lightyears = parsecs *3.26
print(str(parsecs) + " parsecs is " + str(lightyears) + " lightyears")
```

Using this code as a foundation, update how `parsecs` is set. Start by creating a variable name `parsecs_input` and setting it to the result of input, which should prompt the user to enter the number of parsecs. Then convert `parsecs_input` to an integer by using `int` and storing it in `parsecs`. Finish by performing the calculation and displaying the result.

Your code should look something like the following:

```python
parsecs_input = input("Input number of parsecs: ")
parsecs = int(parsecs_input)
lightyears = parsecs * 3.26

print(parsesc_input + " parsesc is " + str(lightyears) + " lightyears")
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.pqtkha.com/programming/technology/python/microsoft-training-python-for-beginners/module-1-write-your-first-python-programs/exercise-collect-input.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
