# Values and Variables

Try Python one line at a time in the REPL, then keep values in variables: numbers for prices and totals, text for names and messages, and the answers people type in. You'll learn the math operators, f-strings for tidy output, and why the number someone types arrives as text, then write a receipt for a cinema's snack bar.

Updated: November 19, 2026

## [Trying Code in the REPL](https://www.ask-codey.com/courses/python-in-depth/topics/python-repl)

1. [Trying Code in the REPL](https://www.ask-codey.com/lessons/python-the-repl) (Novice): The REPL is Python's interactive prompt, where you type one line at a time and see its value at once, which makes it the quickest place to check a calculation or try an idea before it goes in a file.

## [Variables in Python](https://www.ask-codey.com/courses/python-in-depth/topics/python-variables-and-names)

1. [Variables: Giving a Value a Name](https://www.ask-codey.com/lessons/python-variables) (Novice): A variable gives a value a name with =, read "gets", so a program can remember it, use it in many places and change it later, and Python stops with a NameError when a line uses a name that hasn't been given a value yet.

## [Numbers in Python](https://www.ask-codey.com/courses/python-in-depth/topics/python-numbers)

1. [Numbers and Math](https://www.ask-codey.com/lessons/python-numbers-and-math) (Novice): Python has whole numbers (int) and decimal numbers (float), seven math operators that follow the order of operations, and round() for the tiny errors decimals carry, which is how a program gets money right to the cent.

## [Text in Python](https://www.ask-codey.com/courses/python-in-depth/topics/python-text)

1. [Strings and f-strings](https://www.ask-codey.com/lessons/python-strings-and-f-strings) (Novice): Text in Python is a string, written in quotes, joined with + and tidied with methods such as strip() and title(), and an f-string drops values into text, with :.2f to show money to two decimal places.

## [Input and Types](https://www.ask-codey.com/courses/python-in-depth/topics/python-input-and-types)

1. [Asking for Input, and Converting Types](https://www.ask-codey.com/lessons/python-input-and-converting-types) (Apprentice): input() asks a question in the terminal and always hands back the answer as text, so a program turns typed numbers into numbers with int() or float() (and numbers into text with str()), checks a value's type with type(), and stops with a ValueError when the text isn't a number.

## [Exercise: Snack Bar Receipt](https://www.ask-codey.com/courses/python-in-depth/topics/exercise-python-snack-bar-receipt)

1. [Exercise: Snack Bar Receipt](https://www.ask-codey.com/lessons/exercise-python-snack-bar-receipt) (Novice): Finish a script that asks a cinema snack bar's customer for their order and prints the receipt, turning typed answers into numbers and showing the subtotal, the 7% tax and the total to the cent, while pytest types the answers in and checks every line.

Source: https://www.ask-codey.com/courses/python-in-depth/chapters/python-values-and-variables
