Teach Your Kids To Code: A Parent-friendly Guide to Python Programming

(vip2019) #1
Numbers and Variables: Python Does the Math 51

words, letters, characters, and sym-
bols, including how to make Python
understand and evaluate certain
strings, like when we wanted to use
a number that the user entered to
perform calculations.
You saw a few examples of syn-
tax errors and learned how to avoid
some of them when you program. You
learned about the list variable type,
which you can use to store lists of
all kinds of values, such as colors =
["red", "yellow", "blue", "green"].
You even found out how Python can
help you with simple calculations,
including long division.
You’ll build on your understanding of variables and data
types as you learn how to use variables to create your own loops
in Chapter 4, use the computer to make decisions in Chapter 5,
and even program the computer to play games in Chapter 6 and
beyond. Variables are the first, crucial programming tools that
help us break down the most complex problems, from video games
to satellites to medical software, into small chunks that we can
solve with code. Work on the samples from this chapter, and create
your own examples, until you’re familiar enough with variables to
dig in to the next chapter.
At this point, you should be able to do the following:


• Create your own variables to store numbers, strings, and lists.


• Discuss the differences between number types in Python.


• Use basic math operators in Python to perform calculations.


• Explain the difference between strings, numbers, and lists.


• Write out short programs as steps in English and then write
those steps as comments to help you build your code.


• Ask for user input in a variety of situations and use that input
in your programs.

Free download pdf