Here - 1000 BiT
Here - 1000 BiT Here - 1000 BiT
uINSTRUCTOR NOTES 13 RANDOM NUMBERS AND THE INT FUNCTION uThis lesson introduces two functions: RND and INT. These are very important in gamesand also handy in making interesting displays like kaleidoscopes.The RND function produces psuedo-random decimal numbers larger than 0 and smallerthan 1. Such numbers are directly usable as probabilities, but integers over some range ^Jsuch as 1 to 6 for a die, or 1 to 13 for a suit of cards are often more directly usable.Your student may be shaky in decimal arithmetic, but all that is required here is ,multiplication of the random number by an integer, and perhaps also addition to aninteger. The computer does the multiplication, of course, so only a rough idea of the ^jdesired result is necessary.After extending the random number to a larger range than 0 to 1, conversion to aninteger is desired. The INT function does this by simply truncating the number, "throwing ^away the decimal part." (For negative numbers the situation is a little more complicated, *>and that rare case is not treated here.)The concept of "rounding off' may be familiar to your student. INT will round off anumber if you first add 0.5 to it.
LESSON 13RANDOM NUMBERS AND THE INT FUNCTIONTHE RND FUNCTIONWhen you throw dice, you can't predict what numbers will come up.When dealing cards, you can't predict what cards each person will get.You need some way to "roll dice" and "deal cards" and do other unpredictable thingswith the computer.Use the RND function to do this. RND stands for "random."Run this program:10REM RANDOM NUMBERS20 PRINT "clrdndn"25 LETN=RND(8)30 PRINT N40 IF N
- Page 25 and 26: OTHER COMMANDS IN PRINT STATEMENTSJ
- Page 27 and 28: LESSON 3 LIST, BOXES IN MEMORYClear
- Page 29: ADDING A LINEYou can add a new line
- Page 35 and 36: THE DELETE KEYThe DEL key is your "
- Page 37 and 38: INSTRUCTOR NOTES 5 TRICKS WITH PRIN
- Page 39 and 40: RULE: The semicolon makes the invis
- Page 41 and 42: Assignment 5:1- Write a program whi
- Page 43 and 44: LESSON 6THE INPUT COMMANDUse INPUT
- Page 45 and 46: YOU WEAR TWO HATS, USER AND PROGRAM
- Page 47 and 48: LESSON 7THE LET COMMAND, GLUING STR
- Page 49 and 50: GLUING THE STRINGSHere is how to st
- Page 51 and 52: LESSON 8THE GOTO COMMAND AND THE ST
- Page 53 and 54: A CAN OF SPAGHETTILook at this: 10
- Page 55 and 56: Assignment 8:1. Just for practice i
- Page 57 and 58: LESSON 9 THE IF COMMANDClear the me
- Page 59 and 60: JtTHE "NOT EQUAL" SIGNTwo signs:= m
- Page 61 and 62: INSTRUCTOR NOTES 10 INTRODUCING NUM
- Page 63 and 64: The thing which is put into the box
- Page 65 and 66: MIXTURES IN PRINTYou can print numb
- Page 67 and 68: INSTRUCTOR NOTES 11TAB AND DELAY LO
- Page 69 and 70: HOW BIG A SPACE CAN TAB( ) MAKE?The
- Page 71 and 72: INSTRUCTOR NOTES 12 THE IF COMMAND
- Page 73 and 74: AN IF INSIDE AN IFThe "teenager" pr
- Page 75: 2. Here is another program. What wi
- Page 79 and 80: ROUNDING OFF NUMBERSPerhaps you kno
- Page 81 and 82: INSTRUCTOR NOTES 14SAVING TO TAPEWe
- Page 83 and 84: The computer automatically turned o
- Page 85 and 86: nnr^nnnnnr^nnLOADING A PROGRAM FROM
- Page 87 and 88: 5. We are ready to put in the next
- Page 89 and 90: n INSTRUCTOR NOTES 15 SOME SHORTCUT
- Page 91 and 92: AN INPUT SHORTCUTInstead of10 PRINT
- Page 93 and 94: WHEN TO USE THE COLON SHORTCUTUse t
- Page 95 and 96: But if we write this line in a prog
- Page 97 and 98: LESSON 16 MOVING PICTURESMOVING THE
- Page 99 and 100: Line 40 waits for you to see this b
- Page 101 and 102: LESSON 17FOR-NEXT LOOPSRemember the
- Page 103 and 104: LOOP VARIABLESTo make sure that eac
- Page 105 and 106: ^ INSTRUCTOR NOTES 18 DATA, READ, R
- Page 107 and 108: STRANGE RULES1. It doesn't matter w
- Page 109 and 110: MIXTURES OF DATAThe DATA statement
- Page 111 and 112: LESSON 19SOUND EFFECTSTurn up the s
- Page 113 and 114: TONES BY THE BUSHELEnter: 10 REM **
- Page 115 and 116: "TM" stands for "timbre." Timbre is
- Page 117 and 118: INSTRUCTOR NOTES 20NAMES, CLOCKS AN
- Page 119 and 120: cAnytimeyou type, the characters ar
- Page 121 and 122: LESSON 21COLOR GRAPHICSADJUST YOUR
- Page 123 and 124: Add these lines to the above progra
- Page 125 and 126: INSTRUCTOR NOTES 22POKEing GRAPHICS
LESSON 13RANDOM NUMBERS AND THE INT FUNCTIONTHE RND FUNCTIONWhen you throw dice, you can't predict what numbers will come up.When dealing cards, you can't predict what cards each person will get.You need some way to "roll dice" and "deal cards" and do other unpredictable thingswith the computer.Use the RND function to do this. RND stands for "random."Run this program:10REM RANDOM NUMBERS20 PRINT "clrdndn"25 LETN=RND(8)30 PRINT N40 IF N