Hardware Reference
In-Depth Information
3. Now change a to be smaller than 5, and see what happens (see Figure 2-4):
a = 3
if a>5 and a<10:
print("between")
FIGURE.2-4 You use an if statement with and to check two or more conditions.
CHALLENGE
Try the preceding example with different numbers, especially numbers close to
5 and 10. Which numbers cause the word “between” to be displayed?
When you are testing programs, it is very useful to test them with lots of different
numbers. One way that you can reduce a possibly infinite amount of testing to
something that is manageable is to look at the conditions of the if statements
and only test around those numbers. In the previous example, I would test 4,5,6
and 9,10,11, and if those numbers work it would be safe to assume that all other
possible numbers work in the program too.
Building a Magic Doormat
Before you can write your game, you first need to build something in the Minecraft
world, to give your program something to interact with. All you really need is a door-
mat. But first, open Minecraft and load the world you've already been using.
1. To place a doormat on the floor, choose an item from the inventory and right-click
to place it on the floor in front of you. Wool is probably a good choice for a doormat.
 
Search WWH ::




Custom Search