Python Sneks Curriculum

Click here to return to the list of pages

Values

Download slides

Values Represent the World

Programming is all about inputting data so that we can manipulate it to get some output. Therefore, we use values to represent the real world as data in the computer.

A map of the earth, but the continents are drawn with 1s and 0s.

Values

Values can represent anything in the real world that we can measure and concretely describe. Distances, temperatures, peoples’ ages, our names, even the text of entire books.

Three images are shown. Each image is a picture with an arrow pointing to a data representation of the concept.
The first picture is a thermometer pointing to the number 23.4 (representing the current temperature).
The second picture is an old woman pointing to the number 74 (representing her age).
The third picture is a book pointing to the introductory text from the first Harry Potter book.

Writing Values

When we write values directly in code, we call them “Literal Values”, as opposed to values in a file or received as input from a user. Sometimes we also call this “Hard Coding a value”. These hard-coded values are usually useful for developing simple programs.

On the left, some code is labeled “Literal Value”

print(7)

A speech balloon points to the 7 and reads “7 is a literal value”.
On the right, some code is labeled “Input from a User”

print(input())

Printing Values

Once we have put data into the computer as values, we need to do something with it. A very simple action is to simply print it out. Soon, we will learn more complex actions. Look at these examples of how we can write literal values and then print them out.

6 lines are shown, alternating between a line of code and the output from running that code.

> print("This will be shown to the user")
This will be shown to the user ```python > print("This is a literal value") ```
This is a literal value ```python > print(142) ```
142

Understanding Values

It is very easy to put values into the computer. However, it is very difficult to immediately understand what those values mean. It is up to us programmers to communicate the meaning of values.

Picture of a person holding up the number 17 on a piece of paper, with a speech bubble that says “This value represents my dog’s age!”