Random number generation is a useful tool in a programmers arsenal. By generating and using random numbers a programmer can create a piece of code that will behave differntly each time.
When we are using pseudocode the first and last numbers we state are included in the possible random choices. In practical implementation this will vary by language. In the pseudocode above RANDOM_INT(1,3) would generate
a random integer between 1 and 3 inclusive. In Python after importing the random module the same could be done by calling random.randint(1,3).
<< Previous: String handling Next: Structured programming >>