---
jupyter:
  jupytext:
    text_representation:
      extension: .Rmd
      format_name: rmarkdown
      format_version: '1.0'
      jupytext_version: 0.8.2
  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.6.5
---

# Strings, variables and expressions

You remember that the following line of code is an *expression* - a recipe that returns a value:

```{python}
10.50
```

We can see that this is an expression, because Jupyter displayed a text
representation of the value that results: `10.5`.

In fact the expression `10.50` is called a *float literal*.

Now consider this expression:

```{python}
"Magneto"
```

It is a recipe that returns a value.  In this case the value is Python's
internal representation of the fragment of text "Magneto".

We can store the result of the expression in a variable, using an *assignment
statement*.

An assignment statement has a *variable name* on the left hand side, then an equals sign
`=`, followed by an expression on the right hand side.

```{python}
villain = "Magneto"
# Show the value
villain
```

Notice the distinction between a *variable name* (no quotes) and the *string
literal* (surrounded by quotes).   A variable name is a name that refers to a
value.  It has to follow the rules of variable names.  A string literal is an
expression, that evaluates to Python's representation of text.

Recall that an assignment is a name on the left hand side, an `=`, and an
expression on the right hand side.  So, what is wrong with this assignment
statement (in fact, there are two things wrong)?  Think how you would explain
what is wrong.  Then make a new cell (Cell menu item, Add Cell Below), copy the
code into the cell, and see what Python says.  Is that what you expected?

```python
"goodie" = Professor X
```

Now fix the cell above so the variable `goodie` gets the value of the text
fragment "Professor X".
