Game Development Reference
In-Depth Information
For example, let's assign different values to two variables named eggs and fizz , like
so:
>>> fizz = 10
>>> eggs = 15
Now the fizz variable has 10 inside it, and eggs has 15 inside it.
Figure 2-5: The "fizz" and "eggs" variables have values stored in them.
Without changing the value in our spam variable, let's try assigning a new value to the
spam variable. Enter spam = fizz + eggs into the shell then enter spam into the
shell to see the new value of spam. Can you guess what it will be?
>>> fizz = 10
>>> eggs = 15
>>> spam = fizz + eggs
>>> spam
25
>>>
The value in spam is now 25 because when we add fizz and eggs we are adding the
values stored inside fizz and eggs .
Summary
In this chapter you learned the basics about writing Python instructions. Python needs
you to tell it exactly what to do in a strict way, because computers don't have common
sense and only understand very simple instructions. You have learned that Python can
Search WWH ::




Custom Search