Learn to Program with Small Basic

Book description

A fun introduction to programming with Small Basic for kids and other beginners.

Publisher resources

View/Submit Errata

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. About the Authors
  5. Brief Contents
  6. Contents in Detail
  7. Foreword
  8. Acknowledgments
  9. Introduction
    1. Who Should Read This Book?
    2. What’s in This Book?
    3. Online Resources
    4. A Note to the Reader
  10. Chapter 1: Introducing Small Basic
    1. What Is a Computer?
    2. What Is a Computer Program?
    3. What Is Small Basic?
    4. The Vision of Small Basic
    5. The Basics of Small Basic
      1. The Small Basic Language
      2. The Small Basic Library
      3. The Small Basic Development Environment
    6. Installing Small Basic
    7. The Small Basic IDE
      1. Opening and Saving Your Work
      2. Sharing Your Work and Importing Games
      3. Copy and Paste; Undo and Redo
      4. Running Your Program and Graduating
    8. Writing and Running Your First Program
      1. Objects and Methods
      2. Naming Your Programs
      3. Files Generated by Small Basic
      4. Helping Hands: IntelliSense and Syntax Coloring
    9. Drawing with Small Basic
      1. Try It Out 1-1
    10. Programming Challenges
  11. Chapter 2: Getting Started
    1. The Parts of a Program
      1. Comments and Statements
      2. Characters and Strings
      3. Arguments and Methods
        1. Try It Out 2-1
    2. Exploring Other Features
      1. Case Sensitivity
      2. Sequential Execution
      3. Displaying Numbers and Doing Math
      4. Joining Strings
        1. Try It Out 2-2
    3. Object Properties
      1. Setting and Changing Property Values
      2. Working with Properties
        1. Try It Out 2-3
    4. Arithmetic Operators
      1. Try It Out 2-4
    5. Programming Errors
      1. Syntax Errors
      2. Logic Errors
      3. Runtime Errors
    6. Programming Challenges
  12. Chapter 3: Drawing Basics
    1. The Graphics Coordinate System
    2. Drawing Lines
    3. Drawing Shapes
      1. Triangles
        1. Try It Out 3-1
      2. Rectangles and Squares
        1. Try It Out 3-2
      3. Ellipses and Circles
      4. Pen Size and Color
      5. Pen Width and Shape Size
        1. Try It Out 3-3
    4. Drawing Text
    5. Inserting Images
    6. Programming Challenges
  13. Chapter 4: Using Variables
    1. What’s a Variable?
    2. The Basics of Using Variables
      1. Assigning Expressions to Variables
      2. Passing Variables to Methods
      3. Changing the Value of a Variable
      4. Using Spaces for Readability
        1. Try It Out 4-1
    3. Rules for Naming Variables
      1. Say What You Mean
      2. Find the Right Length
      3. Stick with Your Style
      4. Let IntelliSense Work for You
      5. Avoid Naming Variables After Methods and Objects
        1. Try It Out 4-2
    4. Simplifying Expressions
      1. Try It Out 4-3
    5. Using Variables to Solve Problems
      1. Try It Out 4-4
    6. Two Kinds of Data
    7. Global Variables
      1. Try It Out 4-5
    8. Programming Challenges
  14. Chapter 5: Drawing Shapes with Turtle Graphics
    1. Meet the Turtle
    2. Moving the Turtle
      1. Absolute Motion
      2. Relative Motion
      3. Coloring Your Steps
      4. Controlling Your Speed
        1. Try It Out 5-1
    3. Introducing the For Loop
      1. Try It Out 5-2
    4. Drawing Regular Polygons
      1. A Star Is Born
        1. Try It Out 5-3
      2. Creating Polygon Art Using Nested Loops
        1. Try It Out 5-4
      3. Endless Graphics
        1. Try It Out 5-5
    5. Programming Challenges
  15. Chapter 6: Getting User Input
    1. Talking to the Computer
      1. Your Number, Please?
      2. Introducing Yourself to Your Computer
      3. Writing Prompts for Input
      4. A Moment of Silence, Please (Pause)
    2. Working with User Input
      1. Converting Fahrenheit to Celsius
        1. Try It Out 6-1
      2. Averaging Numbers
      3. Reading Text
        1. Try It Out 6-2
    3. Programming Challenges
  16. Chapter 7: Empowering Programs with Math
    1. Exponent Methods
      1. SquareRoot() and Good Old Pythagoras
      2. Powerful Powers
        1. Try It Out 7-1
    2. Rounding Methods
      1. Traditional Rounding
      2. Rounding to the Nearest Hundredth
        1. Try It Out 7-2
    3. Abs(), Min(), and Max() Methods
      1. Try It Out 7-3
    4. The Remainder() Method
      1. Try It Out 7-4
    5. Random Numbers
      1. Try It Out 7-5
    6. Trigonometric Methods
      1. Try It Out 7-6
    7. Programming Challenges
  17. Chapter 8: Making Decisions with If Statements
    1. The If Statement
      1. Relational Operators
        1. Try It Out 8-1
      2. Complex If Conditions
        1. Try It Out 8-2
      3. Comparing Strings
    2. The If/Else Statement
      1. Try It Out 8-3
    3. Nested If and If/Else Statements
      1. Try It Out 8-4
    4. The Goto Statement
      1. Try It Out 8-5
    5. Programming Challenges
  18. Chapter 9: Using Decisions to Make Games
    1. The If/ElseIf Ladder
      1. Letter Grades
      2. The Bug on the Ladder
        1. Try It Out 9-1
    2. Let’s Get Logical
      1. Logical Operators in the Zoo
      2. The And Operator
      3. The Or Operator
      4. The Cosmic Order of Evaluation
        1. Try It Out 9-2
    3. The Shapes Object
      1. Try It Out 9-3
    4. Create a Game: Guess My Coordinates
      1. Step 1: Open the Startup File
      2. Step 2: Set Up the Game
      3. Step 3: Hide the Star
      4. Step 4: Let the User Guess
        1. Try It Out 9-4
    5. Programming Challenges
  19. Chapter 10: Solving Problems with Subroutines
    1. Why Use Subroutines?
    2. Writing Subroutines
      1. Try It Out 10-1
    3. Subroutine Input and Output
      1. Try It Out 10-2
    4. Nesting Subroutines
      1. Try It Out 10-3
    5. Create a Dragon Game
      1. Step 1: Open the Startup File
      2. Step 2: Write the SetUp() Subroutine
      3. Step 3: Add a Bit of Chance
      4. Step 4: Let the Player Know What’s Going On
      5. Step 5: Get the Player in the Game with GetChoice()
      6. Step 6: Process the Player’s Choice
      7. Step 7: Add Motion with MoveKnight()
      8. Step 8: Shoot Arrows with ShootArrow()
      9. Step 9: Swing the Sword with StabDragon()
      10. Step 10: Breathe Fire
        1. Try It Out 10-4
    6. Programming Challenges
  20. Chapter 11: Event-Driven Programming
    1. GraphicsWindow Events
      1. Create Patterns with the MouseDown Event
        1. Try It Out 11-1
      2. Fire Missiles with the KeyDown Event
        1. Try It Out 11-2
      3. Make a Typewriter Using the TextInput Event
        1. Try It Out 11-3
      4. Draw Pictures with the MouseMove Event
        1. Try It Out 11-4
    2. Useful Tips
    3. Create a Gold Rush Game
      1. Step 1: Open the Startup File
      2. Step 2: Move the Turtle
      3. Step 3: Move the Bag of Gold
      4. Step 4: Update the User’s Score
        1. Try It Out 11-5
    4. Programming Challenges
  21. Chapter 12: Building Graphical User Interfaces
    1. Design a User Interface with the Controls Object
      1. Step 1: The Design Phase
      2. Step 2: Program Interactivity
        1. Try It Out 12-1
    2. Make a Colorful Drawing Program
      1. Try It Out 12-2
    3. Explore Circuits with Code
      1. Step 1: Open the Startup File
      2. Step 2: Add the Main Code
      3. Step 3: Toggle the Switch
      4. Step 4: Respond to Changes
      5. Step 5: Update the Program’s Interface
        1. Try It Out 12-3
    4. Program Your Own Image Viewer
      1. Try It Out 12-4
    5. Programming Challenges
  22. Chapter 13: Repeating For Loops
    1. The For Loop
      1. Try It Out 13-1
      2. Magical Moving Text
        1. Try It Out 13-2
      3. Adding ’em Up
        1. Try It Out 13-3
      4. Formatting Your Output
        1. Try It Out 13-4
      5. Drawing All Kinds of Lines
        1. Try It Out 13-5
    2. Changing the Step Size
      1. Counting Down by Twos
      2. Making a Fractional Step
        1. Try It Out 13-6
    3. Nested Loops
      1. Tessellating for Fun
        1. Try It Out 13-7
      2. Multiple Nesting Levels
        1. Try It Out 13-8
    4. Programming Challenges
  23. Chapter 14: Creating Conditional While Loops
    1. When to Use While Loops
    2. Writing a While Loop
      1. Try It Out 14-1
    3. Validating Your Inputs
      1. Try It Out 14-2
    4. Infinite Loops
      1. Try It Out 14-3
    5. Create a Rock-Paper-Scissors Game
      1. Step 1: Open the Startup File
      2. Step 2: Add the MouseDown Handler
      3. Step 3: Switch the Images
      4. Step 4: Announce the Winner
        1. Try It Out 14-4
    6. Programming Challenges
  24. Chapter 15: Grouping Data in One-Dimensional Arrays
    1. Getting Started with Indexed Arrays
    2. Array Basics
    3. Initializing Arrays
      1. Try It Out 15-1
    4. Filling Arrays with a For Loop
      1. Constant Initialization
      2. Random Initialization
      3. Formula Initialization
      4. User Initialization
        1. Try It Out 15-2
    5. Displaying Arrays
      1. Try It Out 15-3
    6. Processing Arrays
      1. Finding the Sum
      2. Finding the Maximum Element
    7. Using String Values in Arrays
      1. Try It Out 15-4
    8. Saving Records
    9. Using Indexed Arrays
      1. Random Selection
      2. A Magic 8 Ball
        1. Try It Out 15-5
    10. Create the Catch Apples Game
      1. Step 1: Open the Startup File
      2. Step 2: Add the Apples
      3. Step 3: Position the Apples
      4. Step 4: Move the Apples
      5. Step 5: Catch or Miss
        1. Try It Out 15-6
    11. Programming Challenges
  25. Chapter 16: Storing Data with Associative Arrays
    1. Associative Arrays
    2. Putting Associative Arrays to Use
      1. Days in French
        1. Try It Out 16-1
      2. Storing Records
        1. Try It Out 16-2
    3. The Array Object
      1. Is It an Array?
      2. How Big Is an Array?
      3. Does It Have a Particular Index?
      4. Does It Have a Particular Value?
      5. Give Me All the Indices
        1. Try It Out 16-3
    4. Your Computer the Poet
      1. Step 1: Open the Startup File
      2. Step 2: Set Up the Graphical User Interface
      3. Step 3: Respond to Button Clicks
      4. Step 4: Write the Poem’s First Line
      5. Step 5: Write the Poem’s Second and Third Lines
        1. Try It Out 16-4
    5. Programming Challenges
  26. Chapter 17: Expanding to Higher-Dimension Arrays
    1. Two-Dimensional Arrays
      1. A Random Matrix
        1. Try It Out 17-1
      2. A Matrix with User Input
      3. Animated Squares
        1. Try It Out 17-2
      4. Using String Indices
        1. Try It Out 17-3
      5. Going Interactive
        1. Try It Out 17-4
    2. Common Operations on Numerical 2D Arrays
      1. Step 1: Add All Elements
      2. Step 2: Find the Sum of Each Column
        1. Try It Out 17-5
    3. Arrays of Three or More Dimensions
      1. Try It Out 17-6
    4. Create a Treasure Map Game
      1. Step 1: Open the Startup File
      2. Step 2: Create the GUI Elements
      3. Step 3: Start a New Game
      4. Step 4: Create a New Treasure Map
      5. Step 5: Draw Objects on the Map
      6. Step 6: Show the Player’s Location
      7. Step 7: Handle Button Clicks
        1. Try It Out 17-7
    5. Programming Challenges
  27. Chapter 18: Advanced Text Magic
    1. The Text Object
      1. Appending Strings and Getting Their Length
        1. Try It Out 18-1
      2. Taking Strings Apart: Substrings
        1. Try It Out 18-2
      3. Changing Case
        1. Try It Out 18-3
      4. Character Coding with Unicode
        1. Try It Out 18-4
    2. Practical Examples with Strings
      1. Counting Special Characters
        1. Try It Out 18-5
      2. Palindrome Number Checker
        1. Try It Out 18-6
      3. Igpay Atinlay
        1. Try It Out 18-7
      4. Fix My Spelling
        1. Try It Out 18-8
      5. Unscramble
        1. Try It Out 18-9
    3. Rhyme Time: The House That Jack Built
      1. Try It Out 18-10
    4. Programming Challenges
  28. Chapter 19: Receiving File Input and Output
    1. The Case for Files
      1. Naming Files
      2. File Organization
    2. The File Object
      1. File I/O Methods
        1. Try It Out 19-1
        2. Try It Out 19-2
      2. File Management
    3. Practical Programs
      1. The Poet
      2. Math Wizard
        1. Try It Out 19-3
    4. Programming Challenges
  29. Where to Go from Here
  30. Index
  31. Updates
  32. Footnotes

Product information

  • Title: Learn to Program with Small Basic
  • Author(s): Majed Marji, Ed Price
  • Release date: April 2016
  • Publisher(s): No Starch Press
  • ISBN: 9781593277024