# Exercise - Format strings

Knowing how to format strings is essential when you're presenting information from a program. There are a few different ways to accomplish this in Python. In this exercise, you use variables that hold key facts about gravity on various moons and then use them to format and print the information.&#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;

## Create the variables

Start by creating three variables, `name`, `gravity`, and `planet`, and set them to the following values:

```
name: Ganymede
planet: Mars
gravity: 1.43
```

Your code should look like the following:

```python
name = "Ganymede"
planet = "Mars"
gravity = "1.43"
```

## Create the template

Now you will create the template to display the information about the moon. You want the output to look like the following:

```
Gravity Facts about {name}
-------------------------------
Planet Name: {planet}
Gravity on {name}: {gravity} m/s2
```

Your code should look like the following:

```python
template = """Gravity Facts about {name}
----------------------------------------
Planet Name: {planet}
Gravity on {name}: {gravity} m/s2
"""
```

## Use the template

With the template created, it's time to use it to display information about the moon! Use the `format` function on `template` to use the template and `print` the information. Set `name`, `plane`t, and `gravit`y to the appropriate values.

Your code should look like following:

```python
print(template.format(name=name, planet=planet, gravity=gravity))
```

## Desired output

When run, the result should look like the following:

```
Gravity Facts about Gannymede
-----------------------------
Planet Name: Mars
Gravity on Ganymede: 1.43 m/s2
```


---

# 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-3-use-strings-in-python/exercise-format-strings.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.
