# Getting user input and commenting

Hey guys, welcome back to the Python basics tutorial! Now I'm gonna tell you how to get input from the user.\
\
Let's say you're trying to make a simple "hello" program.

```python
name = 'Mark'
print('Hi, ' + name)
```

Right? But the user won't be able to edit the variables themselves, so you need a way of getting input from them.\
Luckily, Python has a really simple way of doing this:

```python
name = input('Enter your name: ')
print('Hi, ' + name)
```

Easy, right? Now run the program, the `>>>` prompt will disappear and you'll see a new prompt "Enter your name: ". Enter your name there and press Enter. You should see 'Hi, {your name}' appear.

{% hint style="info" %}
Values returned by `input` are always strings.
{% endhint %}

To make an adder:

```python
a = int(input('Enter the first number: '))
b = int(input('Enter the second number: '))
print(a + b)
```

Run it and enter the values, and you'll see the sum of them printed.

{% hint style="info" %}
We use `int()` to convert the inputs to integers to get the expected result as shown in the previous chapter.
{% endhint %}

## Commenting

Let's say you have a really complicated program. You need to explain it to someone. How do you do this? You can't just

```python
The following line prints the value of a.
print(a)
```

Since "The following line prints the value of a." is not valid Python code, it will cause a `SyntaxError`. To explain code you use comments which start with a # and are ignored:

```python
# Print the value of a
print(a)
```

Easy! To make multi-line comments or "docstrings" use triple quotes:

```python
"""
This is a multi line comment also know as a docstring
"""
# This is a regular comment.
print('Hello')
```

From now on, I'll be using comments to show the output of the code too.

## Homework

Get the user's name and age, add them together to make a single string and print it out.


---

# 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://memoryerror.gitbook.io/python-basics/getting-user-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.
